Java-oop Stack

Source: Internet
Author: User

1 What is the difference between head and stack?

Stack (stack) and heap (head) are places where data is stored in memory, the difference is:

The 1 stack holds the basic type variables and objects applied, when released after the scope is exceeded, the heap holds the new out-of-sum objects and arrays;

2 heap can dynamically allocate the size of the memory, the God save time does not have to tell the compiler first, the Java garbage collector will automatically reclaim these unused data, and the existence of the stack of data size and lifetime must be deterministic, lack of flexibility. The stack is accessed faster than the heap, after the registers that are directly located on the CPU. Heap due to the dynamic allocation of memory at runtime, access speed is slow;

3 stacks of data can be shared, such as the literal 3, etc.; heap can not

4 stack is a linear set, its addition and deletion of element amount operation should be completed in the same paragraph, the stack is processed in a last-in, first-out manner, the stack address is continuous, can be accessed randomly.

Java-oop 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.