Reference type: Array, class, Interface
Each data type has many characteristics, such as its size and necessity. I 'd like to write it here. The unit of bit about the size is bit. This is what we often call small B, and Big B refers to byte, which is a byte for Chinese translation. 8bit = 1 Byte. About the size of B, let's talk about the situation we encounter here, because many people are confused about this. When we install broadband, we often ask how much bandwidth it is. For example, I use 10 m broadband, but don't forget that the operator uses small B as the unit. You can see the network card traffic calculation directly. However, the size of files in the operating system is in the unit of B. In this case, there is a difference. For example, the download speed of 10 m should be 10 m. Check out thunder. The maximum download speed is around MB. In this way, the equation is: 10 Mb/s = 1.25 MB/s
| Type |
Size (bits) |
Remarks |
| Byte |
8 |
|
| Short |
16 |
|
| Int |
32 |
|
| Long |
64 |
|
| Float |
32 |
|
| Double |
64 |
|
| Char |
16 |
JAVA is unicode encoding |
| Boolean |
1 |
Ture/flase |
Basic type conversion
Automatic conversion, one principle is small to big.
Byte-> short (char)-> int-> long-> float-> double
Forced type conversion
Conversion between basic types. Java type check is very strict, from low-precision conversion to high-precision explicit conversion is not required, double d = 123 ;. But in turn, for narrow conversion, from high precision to low precision, or one type to another type, you must use forced type conversion. Java provides a secure conversion mechanism, but whether the results are expected or not is guaranteed by yourself.
Double d = 12.5;
Float f = (int) d; // The result is 12 instead of 13.
◆ Register: we cannot control it in the program
◆ Stack: stores basic data and object references, but the object itself is not stored in the Stack, but stored in the Stack.
◆ Heap: stores the data reference type generated by new.
◆ Static domain: static members defined by static in objects
◆ Constant pool: stores constants.
◆ Non-RAM Storage: permanent storage space such as hard disk