The Java language provides eight basic types: six numeric types (four integers, two floating-point types), a character type, and a Boolean type.
| Basic type |
Meaning |
Number of occupied digits |
Range of desirable values |
Default value |
| Byte |
BYTE type |
8bit |
[-128,127] |
0 |
| Short |
Short-integer data |
16bit |
[ -65526,65525] |
0 |
| Int |
Integral type data |
32bit |
[ -2147483648,2147483647] |
0 |
| Long |
Long-integer data |
64bit |
[ -9223372036854775808,9223372036854775807] |
0 |
| Float |
Single-precision floating-point number |
32bit |
|
0.0f |
| Double |
Double-precision floating-point number |
64bit |
|
0.0d |
| Char |
16-bit Unicode characters |
16bit |
[0,65525] |
|
| Boolean |
Boolean type |
Not clear |
True;false |
False |
Note the point:
(1) The integer data base type (Byte/short/int/long) in 4 is an integer represented by a signed, twos complement, so assuming that the number of bits is nbit, the range is [ -2^n,2^n-1];
(2) Floating-point numbers cannot be used to accurately represent a specific value
For more information on the basic types, refer to: http://www.runoob.com/java/java-basic-datatypes.html
For a Boolean occupancy, refer to: https://www.jianshu.com/p/2f663dc820d0
8 Basic types of Java