1. Class Members are automatically initialized. The basic type is always initialized to 0 first (boolean is false, (char) 0), and the object reference is initialized to null;
2. Specify initialization for class members. You can initialize basic and non-basic type objects in the class member definition or constructor (including other methods), but this does not prevent automatic initialization from starting first;
3. the initialization sequence is determined based on the sequence defined by class members;
4. Static members will be initialized only when they are accessed for the first time (class objects are loaded for the first time) and will not be initialized after that. The initialization sequence is static first and non-static;
5. initialization of the export class is the process from the base class (top layer) to the export class, which is initialized sequentially.
6. Call Sequence of the constructor
A. Before any other event occurs (when the class object is loaded), the bucket allocated to the object is initialized to a binary value of 0 (refer to 1)
B. Call the base class Constructor (for class initialization, refer to 1 ~ 5 );
C. initialize class members in declared order;
D. constructor of the call class;
E. This is a recursive process, starting from the root until the bottom-layer export class.
7. Object clearing is in the opposite order of initialization.
8. Compile a beneficial rule of the constructor to make the object normal in the simplest way possible. If possible, avoid calling other methods. The only method that can be safely called in the constructor is the final method in the base class (also applicable to private methods ).