Understanding of space heap space of beginner java--stack

Source: Internet
Author: User

1.Person Pangzi; This is in the "open space" in the stack space

Pangzi=new person (); This is assigned to the heap space

The last two steps are doing things that correspond to space.

2. Value type directly into the stack space, such as AF, the reference type into the heap space, the stack space has an "index address", such as when the need for B, in the stack space after looking for "index address" corresponding to find the heap space "details."

Therefore, the value type is "fast" and the reference type is "flexible".

Example string S = "ABCDEFG ... Z ", then s corresponds to the stack space," ABCDEFG ... Z "corresponds to the heap space.

Example int A = 10;int F = a;int A = 11; At this time F is still 10. Since the assignment of a value type is copy, the copy is deposited, and the re-assignment of a does not affect the generated copy, then f is unchanged, 10.

Another: int A = 1234l;//here error, not "big box of Things (Long)" Ready "in a small box (int)", because there is "not fit" possible.

In the case of "accommodates" there is an int a = (int) 1234L; it is feasible to cast.

Example reference type BC point to heap space sos,d point to heap space SBS, if D cancels or changes points to, then SBS does not correspond, that becomes garbage, is detected after deletion.

Understanding of space heap space of beginner java--stack

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.