Object memory Distribution in Java

Source: Internet
Author: User

1. variables are stored in the stack is saved is the data is not a reference address so a variable is a value, one for each

int a = 1;

int b = A;

b = 2;

A results for the 1,b result of 2 A does not change

2. The object's data is stored in the heap, and the reference address is stored in the stack of the call process is first to the stack to obtain a reference address, and then through the reference address to find the corresponding data in the heap, so when the value of an object changes other references the value of the object will also change

Object memory Distribution in Java

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.