Stack Stack heap

Source: Internet
Author: User

Stack (Stack)
Stacks (Stack) aka Stack, which is a linear table with limited operations. The limitation is that only one end of the table is allowed to insert and delete operations. This end is called the top of the stack, and the opposite end is called the bottom of the stack. Inserting a new element into a stack, also known as a stack, a stack, or a stack, is to put a new element on top of the stack, making it a new stack top element, deleting an element from a stack, or making a stack or fallback, by removing the top element of the stack and making its adjacent elements a new stack top element. In computer science, a linear table that restricts insertion or deletion only at the end of a table. The stack is a data structure, which stores it according to the principle of last-in, first-out, the first data is pressed into the bottom of the stack, the final data is at the top of the stack, and the data is ejected from the top of the stack when it needs to be read. A stack is a special linear table that can be inserted and deleted only at one end. Accumulate items in buckets, pile them in at the bottom, and then go to the pile with one piece. Take the walk, can only be taken from one of the above. Both reading and fetching are performed at the top, and the bottom is generally motionless. A stack is a data structure similar to a bucket of stacked items, where one end is called the top of the stack and the other end is called the bottom of the stack. Insertion is generally called a stack, and deletion is called a fallback. A stack is also called a LIFO table.Heap (heaps)Heap memory is another area of memory that differs from the stack, global data area, and code area. The heap allows a program to dynamically request a size of memory space at run time.
1.heap is a heap and stack is a stack.
2.stack of space is automatically allocated and freed by the operating system, and heap space is manually applied and released, and the heap is commonly assigned with the New keyword.
3.stack space is limited, and the heap space is a large free zone. In Java, if you just declare an object, it is assigned an address space in the stack memory, and if you instantiate it again, it is assigned an address in heap memory.
4. Example: data type variable name; So define something in the stack area. such as: Object a =null; Allocate only the space new data type () in stack memory, or malloc (length); Something like this is defined in the heap area such as: Object B =new Object (); Allocates space in heap memory

Stack Stack heap

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.