Refer to the public number Java leader in-depth understanding of Java object Creation process original blog.csdn.net/justloveyou_/article/details/72466416Java object creation Process: 1. Class loading process
Preparation stage: Loads the compiled. class file into memory, allocates memory for class variables (static class member variables), and sets the class variable initial value (0 value) stage.
Initialization phase: Is the process of actually starting to execute the Java program defined in the class and initializing the class variable as the program ape intends.
2. class instance loading process
Prep phase: Allocates memory for class instance variables and is given the default value (0 value).
Initialization stage: For the class instance variable according to the program ape intention to initialize the value, can be divided into class instance variable initialization, class instance code block initialization and constructor initialization.
3. In general, the general process of class instantiation is the constructor of the class constructor for the parent class constructor <clinit> (), the subclass constructors <clinit> (), the parent class, and the instance code block, the parent class. Constructors for child classes, member variables and instance code blocks, subclasses
Java class initialization and instantiation summary