The 8 Primitive Types
Integers
There are 4 Integer types in Java, which account for half the primitive types. The types are long, int, short, byte.
Integer Type |
Size |
Explanation |
long |
8 bytes |
Stores a value between -9223372036854775808 and 9223372036854775807 |
int |
4 bytes |
Stores a value between -2147483648 and 2147483647 |
short |
2 bytes |
Stores a value between -32768 and 32767 |
byte |
1 byte |
Stores an integer between -128 and 127 |
Other Primitives
Type |
Size |
Explanation |
double |
8 bytes |
An IEEE 754 double precision number. It stores a value between -1.7976931348623157 E308 and 1.7976931348623157 E308 |
float |
4 bytes |
An IEEE 754 floating point number. It stores a value between -3.4028235 E38 and 3.4028235 E38 |
char |
2 bytes |
A two–byte Unicode character |
boolean |
1 byte |
It holds a true or false |