Java stack and stack

Source: Internet
Author: User

In Java, heap and stack are physical storage locations. Both heap and stack are stored in memory and randomly accessed in memory (RAM.

1. STACK: the basic types of automatic variables and object references are stored and in the stack. All items stored in the bucket have an exact life cycle.

2. Heap: All Java objects are stored in heap. It can also be said to be class objects generated with the new keyword.

The benefit of heap difference and stack is that the compiler does not need to know how long the stored data will survive in the heap. Therefore, there is great flexibility. Of course, it takes more time to allocate and clean the storage with the heap.

In addition, the constant value is directly placed inProgramCodeInternally, they are stored together with program code. They will never be changed.

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.