Java data type, java Basic Data Type
(1) Basic Data Types
1. Integer type
The first digit is the symbol bit, 0 is positive, and 1 is negative. When the first digit is 1, all the digits are reversed and 1 is the opposite positive number.
Integer |
Bytes |
Maximum storage data |
Data storage range |
Byte |
1 (8bit) |
28-1 |
-27 ~ 27-1 |
Short |
2 (16 bit) |
216-1 |
-215 ~ 215-1 |
Int |
4 (32bit) |
232-1 |
-231 ~ 231-1 |
Long |
8 (64bit) |
264-1 |
-263 ~ 263-1 |
2. Floating Point Type
The first is the symbol bit, the middle is the index bit, indicating the factorial of 2, followed by the ending number bit (less than 1), and the first is the index symbol bit,
Number: (1 + m) * 2e
Floating Point Type |
Bytes |
Data range |
Remarks |
Float-single precision |
4 (32bit) |
3.4e-45 ~ 1.4e38 (-2128 ~ 2128) |
Add f or F at the end of the direct assignment. |
Double-Double precision |
8 (64bit) |
4.9e-324 ~ 1.8e308 (-21024 ~ 21024) |
You can add d or D at the end of the direct assignment. |
Symbol bit |
Exponential e |
M (0 <m <= 1) |
0/1 |
Symbol bit (first) |
Remaining bit |
2-1 |
2-2 |
2-3 |
...... |
Float |
1 digit |
7-digit |
23 |
Double |
1 digit |
10 digits |
52 |
3. Balanced
Char → A single Unicode character or 16-bit non-negative integer referenced by single quotes. It occupies two bytes and represents one character. There are two types of writing:
Digital: 0 ~ Integer between 216-1
Letter: one character referenced by single quotes. It can be any character, including punctuation marks, numbers, uppercase/lowercase English letters, Japanese letters, and Chinese characters. It is a Unicode number.
4. boolean (logical)
Boolean, which has only two values: true/false, or a logical expression. It cannot be expressed as 0, 1, or a string of "true ".
Supplementary description of data value range:
(2) Reference Data Types
All classes defined using class, interface, and abstract;
String is also a class defined by java. Its data storage method is the same as the basic data type, but String is not the basic data type;