Loading order of classes in JVM

(1) Parent class static code block (including static initialization block, static properties, but not static methods)
(2) Sub class static code block (including static initialization block, static properties, but not static methods)
(3) Parent Class non-static code block (including non-static initialization block, non-static properties)
(4) Parent class constructor
(5) Sub-class non-static code block (including non-static initialization block, non-static properties)
(6) Sub-class constructor
Among them: the static blocks in the class are executed in the order of declaration, and (1) and (2) are executed when the new class instance does not need to be called (meaning it is executed when the class is loaded into the method area)

Guess you like

Origin blog.csdn.net/qq_41134324/article/details/109157088