First
The initialization sequence is related to the declared sequence of variables, and the initialization of variables (including primitive types and Object Reference) must be before all methods are called, and even the constructor must be later.
Static Data initialization static data initialization all static data is stored in a storage area, and Initialization is only performed once. The initialization order is as follows: 1. static (if initialization has passed, the initialization will not be repeated) 2. non-static but there is a saying in the book: "static data are initialized only when the first XX object is created or the first static access occurs" That is to say, static variables are not initialized when they are not required. It is not necessary to create an object for a class or to use a class. staticvariable access. Explicit static statement initialization explicit static initialization syntax: static {
// Clses ...} the initialization sequence is the same as that of static variables. If you create a class pair or access a static variable in the class, the explicit statements in the static domain will be triggered by non-static instance initialization syntax :{
Clauses...} instance initialization always completes the statements in parentheses before calling the constructor.