Java8 basic data types
byte
- Basic type: byte
- Wrapper class: java.lang.byte
- Size: 8 bit
- Default value: 0
- Value range: -128 to 127 byte. MIN_VALUE byte. MAX_VALUE
- Binary complement representation
short
- Basic type: short
- Wrapper class: java.lang.short
- Size: 16 bit
- Default value: 0
- Value range :(-2)^15 to 2^15-1 short.min_value byte. MAX_VALUE
- Binary complement representation
int
- Basic type: int
- Wrapper class: java.lang.INTEGER
- Size: 32 bit
- Default value: 0
- Value range :(-2)^31 to 2^31-1 integer.min_value integer.max_value
- Binary complement representation
long
- Basic type: long
- Wrapper class: java.lang.long
- Size: 64 – bit
- Default value: 0L
- Value range :(-2)^63 to 2^63-1 long.min_value long. MAX_VALUE
- Binary complement representation
float
- Base type: float
- Wrapper class: java.lang.float
- Size: 32 bit
- Default value: 0.0f
- Value range: 2^(-149) to 2^128-1 float. MIN_VALUE float. MAX_VALUE
- IEEE754 standard
double
- Base type: double
- Wrapper class: java.lang.double
- Size: 64 – bit
- Default value: 0.0D
- Value range: 2^(-1074) to 2^1024-1 double. MIN_VALUE double. MAX_VALUE
- IEEE754 standard
char
- Base type: char
- Wrapper class: java.lang.Character
- Size: 16 bit
- Default value: \u0000(0)
- Value range: \u0000(0)~\ UFFFF (65536) character.min_value character.max_value
- Unicode characters
boolean
- Basic type: Boolean
- Wrap class: java.lang.Boolean
- It has no size and represents only literal values true/false
other
-
All numeric types are signed, and there are no unsigned numeric types in Java
-
Short can only write 5 digits, int can only write 10 digits, and long can only write 19 digits, and any more will report an error.
-
Float can only be accurate to seven digits from left to right, including integers (0 does not count, 0.123)
-
Double from left to right is accurate to only 16 digits, including the whole number. If the whole number exceeds 7 digits, it is automatically represented by the E exponent