Eight basic types of data in Java:
| Data type |
The number of bytes occupied |
Number of placeholders (binary digits) |
can represent range |
Default value |
Packing class |
Note |
| Byte (bytes) |
1 |
8 |
-128-127 |
0 |
Byte |
|
| Short (shorter integer type) |
2 |
16 |
|
0 |
Short |
|
| int (int) |
4 |
-2147483648-2147483648 |
0 |
integer |
| Long (integer) |
8 |
64 |
-9233372036854477808-9233372036854477808 |
0 |
Long |
|
| Float (float type) |
4 |
32 |
-3.40292347e+38-3.40292347e+38 |
0.0f |
Float |
|
| double (double type) |
8 |
-1.79769313486231570e+ 308-1.79769313486231570e+308 |
0.0d |
double |
| char (character) |
2 |
' \u0000-u\ffff ' |
' \u0000 ' |
|
| Boolean (Boolean) |
1 |
8 |
True/false |
False |
Boolean |
Theoretically occupies 1bit,1/8 bytes, the actual processing by 1byte processing |
Java is encoded using Unicode. Each byte occupies 8 bits. Your computer system should be a 32-bit system, so that each int is 4 bytes
Comparison memory of basic data types in Java