Java storage and java object creation process, storage java object Process
Java storage:
1) Register: This is the fastest storage zone located inside the processor. However, the number of registers is limited, so registers are allocated as needed. We cannot perform operations directly.
2) STACK: it is located in general-purpose RAM and can be directly supported from the processor through the stack pointer. The stack pointer moves down to allocate new memory. If you move it online, the memory will be released. However
When creating a program, you must know the specific lifecycle of all items stored in the stack, so as to move the pointer up and down. It generally stores basic types and java object references.
3) Heap: It is located in general-purpose RAM and stores all java objects without knowing the specific lifecycle.
4) constant storage: constant values are usually directly stored in the program code.
5) Non-RAM storage: data exists completely outside the program, and can exist without the control of the program. It is to convert objects into things that can be stored on other media. Such as stream object and Persistent Object
Object creation process:
1): the constructor is actually a static method even if no static method is displayed. Therefore, when you create an object for the first time or call a static method or static domain for the first time, the java interpreter must find the class path and locate the class file.
2): load the class file and execute static methods or variables. Therefore, static Initialization is only initialized once during class loading.
3): When you create an object using new, sufficient storage space is allocated to the object on the heap.
4): clears this area. In this case, the basic member variables or references in the object are automatically initialized by default. The number is zero, and the reference is null.
5): Execute all initialization actions that appear in the field definition.
6): Execution constructor.