The difference between heap and Stack in Java:
The heap and stack that we usually say is actually the virtual machine stack and heap in the Java Virtual machine, why is the virtual machine stack, because the stack is divided into two, one is the local method stack, and the other is the virtual machine stack that we usually say. The virtual machine stack is thread-private, which means it has the same life cycle as the thread. When we use a method, a stack frame is created in the virtual machine stack to hold information such as the local variable table, the operand stack, the dynamic link, and the method interface. The heap is a thread-shared zone. For example, the location of the object we created with new () is located in the heap. The heap can also be subdivided into the old age (Eden) and the Cenozoic (from Survior and to Survior). such as GC (garbage collection) is carried out on the heap.
Differences between heap and Stack in Java