There are eight basic types of Java, the basic types can be divided into three categories, character type char, Boolean and numeric type Byte, short, int, long, float, double. Numeric types can also be divided into integer type Byte, short, int, long, and floating-point type float, double. Numeric types in Java do not have unsigned, and their range of values is fixed and will not change as the machine hardware environment or operating system changes. In fact, there is another basic type Void in Java, which also has the corresponding wrapper class java.lang.Void, but we can't manipulate them directly. The types in 8 indicate the scope as follows:
Byte:8 bit, the maximum amount of storage data is 255, the range of data stored is between -128~127.
Short:16 bit, the maximum data storage is 65536, the data range is between -32768~32767.
Int:32 bit, the maximum data storage capacity is 2 of 32 times minus 1, the data range is negative 2 31 times to positive 2 of 31 times minus 1.
Long:64 bit, the maximum data storage capacity is 2 of 64 times minus 1, the data range is negative 2 63 times to positive 2 of 63 times minus 1.
Float:32 bit, the data range is 3.4e-45~1.4e38, the direct assignment must be followed by the number F or F.
Double:64 bit, the range of data in 4.9e-324~1.8e308, the value can be added D or D can not add.
Boolean: Only True and false two values.
Char:16 bits, stores Unicode codes, and assigns values in single quotes.
Java determines the size of each of the simple types. These sizes do not change as the structure of the machine changes. This immutable size is one of the reasons why Java programs have a strong ability to migrate. The following table lists the simple types defined in Java, the number of bits consumed, and the corresponding wrapper classes.
Simple Type |
Boolean |
Byte |
Char |
Short |
Int |
Long |
Float |
Double |
void |
Number of binary digits |
1 |
8 |
16 |
16 |
32 |
64 |
32 |
64 |
-- |
Wrapper class |
Boolean |
Byte |
Character |
Short |
Integer |
Long |
Float |
Double |
Void
|
reproduced from: http://www.cnblogs.com/doit8791/archive/2012/05/25/2517448.html