Understanding of stacks in Java __java

Source: Internet
Author: User

The object is placed inside the heap, and the base type data is placed on the stack.


Heap: Objects to be put out of new
Stacks: Putting basic type data and references to objects (equivalent to pointers, but the object itself is still in the heap)
Chang: public static final holds string constants and basic types of constants

Static fields: Putting static member statically defined


For right, stacks are faster than heaps.
Stack recycling mechanism: When the block ends, the basic data type is not used, it automatically destroyed

The recycle mechanism of the heap: it is automatically judged by the virtual machine


The basic type of packaging is actually the object, so put it in the heap.
New objects are created when they are run.
Wrapper base Object Class (String Integer and so on) more specific to see blog

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.