Native type |
Number of occupying positions |
Whether to sign bit |
Minimum value |
Maximum Value |
Default value |
Packing class |
Note |
Boolean |
1 |
Not with |
—— |
—— |
False |
Boolean |
The Boolean type is the lonely queen she can't convert with other types |
Byte |
8 |
Take |
-2^7=-128=byte.min_value |
2^7-1=127=byte.max_value |
0 |
Byte |
Frequently used in IO streams |
Char |
16 |
Not with |
' \u0000 ' =0=character.min_value |
' \uffff ' =2^15*2-1=65535=character.max_value |
' \u0000 ' |
Character |
It is recommended that you use the wrapper class character instead of the original type Char,char a character only as a character, using character to determine if a character is a secondary character. such as this I cannot knock out the symbol: |
|
Short |
16 |
Take |
-2^15=short.min_value |
2^15-1=short.max_value |
0 |
Short |
Historical legacy types, no longer being used |
Int |
32 |
Take |
-2^31=integer.min_value |
2^31-1=integer.max_value |
0 |
Integer |
Long |
64 |
Take |
-2^63=long.min_value |
2^63-1=long.max_value |
0 |
Long |
Use in cases where int cannot be stored |
Float |
32 |
Take |
1.4e-45f=float.min_value |
3.4028235e38=float.max_value |
0.0f |
Float |
Use when high-precision requirements for memory requirements are not high |
Double |
64 |
Take |
4.9e-324=double.min_value |
1.7976931348623157e308==double.max_value |
0.0d |
Double |
Note
|
Although float is the same as the int placeholder, but float can store a value much larger than int, see Integer.max_value and Float.max_value, not only that float is much larger than long, but also that Double is n times greater than long. Therefore, a long can not be stored in a number in a float or double. |
Here the Boolean and char unsigned number is my own addition, although the Java core technology Volume one says: "Java does not have any unsigned type", but the Boolean only one, can only put themselves, how to put the sign bit? From the value range of char, Char is definitely a range of unsigned numbers!
|
Nem represents N*10 's M-Square, ne-m represents one of the M-sub-points of n*10 Java Core Technology Volume one indicates the value range of float type is ±3.40282347e38 personal feeling is wrong!
|
Nem represents N*10 's M-Square, ne-m represents one of the M-sub-points of n*10 Java Core Technology Volume one indicates the value range of float type is ±3.40282347e38 personal feeling is wrong!
|
Deep Anatomy of Java data types