Java has exactly two kinds of value
A primitive holds the value itself. There are exactly eight, and Java fixes their sizes on every platform — unlike C, where int can be 2 or 4 bytes.
| Type | Bytes | Range | Default |
|---|---|---|---|
byte |
1 | -128 to 127 | 0 |
short |
2 | -32,768 to 32,767 | 0 |
int |
4 | -2,147,483,648 to 2,147,483,647 | 0 |
long |
8 | about -9.2 x 10^18 to 9.2 x 10^18 | 0L |
float |
4 | about 7 digits of precision | 0.0f |
double |
8 | about 15 digits of precision | 0.0d |
char |
2 | 0 to 65,535, one UTF-16 unit | ' |