There are 8 basic data types in Java, such as the following:
- Shaping: int, byte,short, long
- Float type: float, double
- Boolean Type: Boolean
- Character type: Char
Table one basic data type
Type |
Number of bytes |
Number of digits |
Range of values |
Example |
Byte |
1 |
8 |
An integer of -27~27-1 |
-128,54,127 |
Short |
2 |
16 |
An integer of -215~215-1 |
1348,6543 |
Int |
4 |
32 |
An integer of -231~231-1 |
0,-1000,345678 |
Long |
8 |
64 |
An integer of -263~263-1 |
987657897,-12 |
Float |
4 |
32 |
An integer of -231~231 |
23.978,87f |
Double |
8 |
64 |
An integer of -263~263 |
2.0231,0.435d |
Char |
2 |
16 |
An integer of -215~215 |
400,a,z,x,-23 |
Boolean |
1 |
8 |
True,false |
True |
Note: (1), Java does not have an unsigned type (unsigned).
(2), double quotation marks indicate a string, which is an object type of Java string, not a data type.
(3), a Boolean type has only two values, and the shaping value and the Boolean value cannot be converted to each other.
Java Basic data types