US Trends

how many primitive data types are there in java

Java has eight primitive data types.

Quick Scoop: Java Primitive Data Types

In Java, primitive types are the most basic building blocks of data — they store simple values directly in memory and are not objects.

The eight primitive data types are:

  1. byte
  2. short
  3. int
  4. long
  5. float
  6. double
  7. char
  8. boolean

A simple way to remember this is: four integer types, two floating-point types, one character type, and one boolean type.

Tiny Example

java

byte b = 10;
short s = 200;
int i = 1000;
long l = 100000L;
float f = 3.14f;
double d = 99.99d;
char c = 'A';
boolean flag = true;

Each of these variables uses one of Java’s eight primitive data types.

TL;DR: If someone asks “how many primitive data types are there in Java?”, the precise answer is: 8 primitive data types.

Information gathered from public forums or data available on the internet and portrayed here.