Stack: Auto-Recycle
Heap: 1. Memory address 2. Initialize default value 3. Garbage collection mechanism
int a = 5; In the stack.
Int[] b =null; At this point, null means that no heap is pointed.
int [] c =new int[5]; Open a space in the heap. At this point, C refers to a memory address.
======================= Learning Dark Horse Java video Learning, speak very vivid, and wisp again. It's time to practice the guitar.
= = Below is the information found online
1. Before looking at the example, make sure you understand the following terms:
Stack : An area allocated by the JVM to hold actions and data references that are executed by the thread. The stack is a running unit, and a thread in Java will have a line stacks corresponding to it.
Heap : An area allocated by the JVM for storing data such as objects.
constant Pool : In the compile phase, a chunk of storage allocated in the heap to store an explicit string,float or integer. For example, String str= "abc"; The ABC string is explicitly declared, so it is stored in a constant pool
The difference between heaps and stacks