Concepts of heap and Stack in Java

Source: Internet
Author: User

1. Some basic types of variables and object reference variables defined in the function are allocated in the stack memory of the function.

2. Heap memory is used to store objects and arrays created by new.

3. After an array or an object has been created in the heap, you can also define a special variable in the stack. Make the value of this variable in the stack equal to the first address of the array or object in the heap memory, and this variable in the stack becomes the reference variable of the array or object. (A reference variable is the name of an array or object, and you can use reference variables in the stack to access arrays or objects in the heap later in the program)

Concepts of heap and Stack 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.