Detailed description of data types in java

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.