Java memory structure and data types

Source: Internet
Author: User

Java Memory Architecture

Memory is a temporary storage of data, his storage speed is very fast, but he is a temporary storage, from the start of storage, power-down or shutdown after the loss of all data. The life cycle of memory is the power-on and shutdown, starting when the calculation, shutdown and nothing. The advantages of fast storage, the shortcomings are easy to break off, if the boot, a little reflection is not, the screen is not lit keyboard mouse, this situation is generally a memory bar problem. Machine blue screen, instruction error is caused by memory.

Program data are stored in memory, not stored on the hard disk because the hard disk is not secure, can read the data. But memory is not the same, memory he is not allowed to read memory data, and fast so our program is stored in memory.

Memory is like a large piece of land that is not beginning, want to plant some vegetables in this land, you can plant, but do not plant the food to other people occupy the place. Memory is also so accessible that some things are allowed for you to access, but if this content is occupied by someone else, it is not permissible for you to try to occupy it again.

Our data is stored in memory, in memory there are a lot of data stored in the cell to be able to save where, but Java is not selective, Java is stored by the virtual machine to proxy.

Memory storage unit: The computer is stored in bits, bits (only the 0 and 1 bits stored) are the smallest storage units. Bytes (8 bits equals 1 bytes) K (1024 bytes equals 1KB) M (1024K equals 1M) G (1024M equals 1G) T (1024G equals 1T) P (1024T equals 1P).

Program data to be stored in memory, you have to choose the size of the storage can not be said small things are also very large to store, such as you have a liter of water then will be stored in the cup. If you have 10 of raw, you have to store in the Cup, it will overflow, large can not be stored in small containers will overflow, small can not be stored in a large container that is very wasteful. 3.3 is shown below:

Figure 3.3

Java Data types

Our programming language data wants to be stored in memory so the first thing to do is to choose a storage size so that it doesn't waste, and the so-called storage size is called the data type. What is a data type? We have to store the data in a type, we need to choose a suitable type for our data to store, not to waste data, not to waste storage size.

Java data types, each with their own storage size, if there are different types, it is necessary to find different data types to store. So the program will be stored in memory to choose the appropriate data type to store.

Numeric type:

1. Integers:

2. Floating point (decimal):

3. Character Type:

4. Boolean type:

The Byte:8 bit represents a byte, which is composed of 8 0 and 1, and he can compose 256 identities. What is a 256 logo? is 8 0 and 1 on that with each other combination, which can combine a total of 256 identities, 8 bits he can inherit the largest number is 255, since he starting from 0, 0~255. So 8-bit is 8 0 and 1 composition, a total of 256 descriptions, 0~255 values. 3.4 is shown below:

Figure 3.4

Short:16 bit, which is 16 0 and 1, he can compose 65,536 logos, 0~65535 a number.

Int:32 bit, which is 32 0 and 1, he can compose 4,294,967,296 logos, 0~4294967295 a number.

The long:64, which is 64 0 and 1, can identify all the values on the earth.

Float:32 Bits, 32 x 0 and 1, decimals can be accurate to about 6 bits.

Double:64 bits, 64 x 0 and 1, decimals can be accurate to about 15 bits.

Char:16 bit, he is represented by the ASCLL character.

Boolean: ID only 0 and 1, he is false true and false meaning, used to judge.

Java memory structure and data types

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.