Active use (class is initialized)
The flag of whether a class is initialized or not is to assign an initial value to a static variable and execute a static block of code.
Active use is sure to initialize the class.
The following are the active use cases:
1. Create an instance of the class
2. The subclass or implementation class of the class is initialized
3. Accessing static variables or methods of this class
4. Use reflection Class.forName (string className) or Class.forName (string className, True (must be true), ClassLoader ClassLoader)
or direct "class name. Class" To create the Java.lang.Class object for the class.
5. Belongs to the Program entry class (the class where the main method resides before the JVM initializes the class before the Main method call)
Passive use
Other uses other than active use are known as passive use,
such as using Classloader.loadclass (String className) and Class.forName (string className, False (must be false), ClassLoader ClassLoader), the class is not initialized.
Several scenarios in which Java classes are used