06-Play from zero javaweb-array in memory storage form

Source: Internet
Author: User

First, the memory partition of the JVM

  To understand the memory storage of an array, first understand the overall memory partitioning of the JVM, see 04JVM memory detail

  

Second, the array in the JVM storage detailed

If we have the following code:

In the above code, the process of creating an array can be divided into three steps:

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

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

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

  

  

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

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

So when you go to the print group, you'll find that you're printing an address, not a value in the array.

  

When executing ages = new int[]{40,50,60}
Initializes a new array in the heap
Re-assigns the address of the array to the ages

  

06-Play from zero javaweb-array in memory storage form

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.