Variables & Data Types

Primitive Data Types

Java has 8 primitive data types.

Numeric Types

TypeSizeRange
byte
1 byte-128 to 127
short
2 bytes-32,768 to 32,767
int
4 bytes~±2 billion
long
8 bytesVery large numbers
float
4 bytesDecimal (less precise)
double
8 bytesDecimal (more precise)

Other Types

TypeDescriptionExample
boolean
true or false
true
char
Single character
'A'

Declaration

int age = 25;
double price = 19.99;
boolean isActive = true;
char grade = 'A';
Visualizer
25
assigned to
25
age

Interactive Visualization

java
Loading...
Output
Run execution to see output...