To sum up the object creation process, assume there is a class named dog:
1. Even if the static keyword is not explicitly used, the constructor is actually a static method. Therefore, when a dog-type object is created for the first time (the constructor can be regarded as a static method), or the static method or static domain of the Dog class is accessed for the first time, the Java interpreter must search for the class path to locate the dog. class file.
2. Load it into dog. Class (this will be learned later. This will create a Class Object (which is really important) and all the actions related to static initialization will be executed. Therefore, static Initialization is only performed once when the class object is loaded for the first time.
3. When creating an object with new dog (), allocate enough storage space for the dog object on the heap.
4. this bucket is cleared, which automatically sets all the basic types of data in the dog object to the default value (0 for numbers, the same for Boolean and numeric types ), the reference is set to null.
5. Execute all initialization actions that appear in the field definition.
6. Execute the constructor.