The basic data types are detailed as follows:
| Type |
Key words |
Length "bits" |
Range of values |
Description |
Wrapper type |
| Integral type |
Byte |
8 (1 bytes) |
[ -128,27] |
Storing byte data (common) |
Byte |
| Short |
16 (2 bytes) |
[ -2^15,2^15-1] |
|
Short |
| Int |
32 (4 bytes) |
[ -2^31,2^31-1] |
Storing ordinary integers (common) |
Integer |
| Long |
64 (8 bytes) |
[ -2^63,2^63-1] |
Store long integers (common) |
Long |
| Character type |
Char |
16 (2 bytes) |
[0,65535]or[0,2^16-1] |
Store one character (common), Unicode encoding |
Character |
| Logic type |
Boolean |
8 (1 bytes) |
True or False |
Storing logical variables (common) |
Boolean |
| Floating point Type |
Float |
32 (4 bytes) |
|
Store floating-point numbers |
Float |
| Double |
64 (8 bytes) |
|
Storing double-precision floating-point numbers |
Double |
Note: 1. Conversion of basic data types: automatic type conversion (implicit type conversion): From small to large type conversions can be done automatically, with the following relationship: casts: From large types to small types require casts, which can result in loss of precision or overflow of 2. Data that can be directly allocated in the stack is the base data type; Reference data type , its object exists in the heap; the default integer type in 3.java is type int, and if you want to define float type, add L (L) after the value, and the default float is double-precision floating point, and to define float type, add F (f) After the value, 4.byte,char. The actual data stored in short three types are integers, using the following rules: Int direct amount can be directly assigned to Byte,char,short, as long as it does not exceed its representation range; Byte,char,short three types participate in the operation, they are converted to the int type in the calculation
Java Foundation--java Basic data types