06-from scratch to JavaWeb-storage format of arrays in memory, 06-javaweb-

Source: Internet
Author: User

06-from scratch to JavaWeb-storage format of arrays in memory, 06-javaweb-

Video: Array Memory Analysis

I. JVM memory Division

To learn about the memory storage of arrays, first understand the overall JVM memory division. For details, see section 04JVM memory.

Ii. Storage of arrays in JVM

Suppose we have the following code:

In the code above, we can divide the process of creating an array into three steps:

1. Declare an array of the int type ages int [] ages;

2. initialize the array new int [] {10, 20, 30} in the heap };

3. Assign the address of the initial array to the ages variable.

 

Is the embodiment of int [] ages = new int [] {} in the memory

We can see that the value of ages is actually the address of the array in the heap.

So when you print the array, you will find that the printed Address is not the value in the array.

When you execute ages = new int [] {, 60}
Initializes a new array in the heap.
The array address is assigned to ages.

 

Related Article

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.