Execution order: Priority from high-Low: Static code block-"Main method-" Construction code block-"construction method.
1, ordinary code block. (can be executed sequentially)
2, constructs the code block. (a block of code that is defined directly in a class and does not have a static keyword is called a construction code block.) Construction blocks are called when the object is created, each time the object is created, and the order in which the code block is constructed takes precedence over the class constructor. )
3, static code block.
Static code block: a block of code declared in Java using the static keyword. Static blocks are used to initialize the class and initialize the properties of the class. Each static block of code is executed only once. Because the JVM executes static blocks of code when the class is loaded, the static block of code executes before the main method.
If a class contains more than one static block of code, it will follow the code defined first, then execute after the definition.
Note: 1 Static code blocks cannot exist in any method body. 2 Static code blocks do not have direct access to instance variables and instance methods, and need to be accessed through instance objects of the class
For more information, see: http://www.cnblogs.com/sophine/p/3531282.html (Sophine)
java-the difference between a common code block, a construction code block, and a static code block.