The preparation stage is the initial value of assigning the system to the variable. And the initialization stage is to assign the programmer's own value to the variable.
The initialization phase is the execution process of the <clinit> () method. The process is as follows
1. The editor collects all assignment actions and static block merge formation <clinit> methods. The collection is determined in the order in which the code appears. and static initialization blocks can only access variables that are defined in the previous variable, for variables that are then assignable, but not accessible
2. The <clinit> method of the parent class is executed before the <clinit> method of this class is executed. And no explicit invocation is required, and the virtual opportunity guarantees that the parent class <clinit> method executes first. The first <clinit> method performed by a virtual machine is java.lang.object
Note: Classes without assignment operations and static initialization blocks do not have a <clinit> method
In addition to classes, there are interfaces. An interface can have an assignment. operation. But the difference is that you do not need to do the parent interface <clinit> method, only after the use of the execution (a bit like lazy loading)
Learn more about Java Virtual machine---class loading mechanism----initialization phase