Class initializes the first time it is "actively used" and assigns the correct initial value to the class (static) variable. In Java code, a correct initial value is given by a class variable initialization statement or static initialization block. And the active use we're talking about here includes:
1. Creating an instance of a class
2. Invoking a static method of a class
3. Using the class's very static field
4. Invoking some of the reflection methods in the Java API
5. Initialize subclasses of a class
6. When a class with the main () method starts
Initializing a class consists of two steps:
1, if the class has a direct parent class, and the immediate parent class has not been initialized, the immediate parent class is initialized first
2. If there is an initialization method for the class, execute this method
Note: Initializing an interface does not require initializing its parent interface.
Initialization of the Java class