For instance variables, it belongs to the Java object itself, and each time a program creates a Java object, it needs to allocate memory space for the instance variable and perform the initialization.
From the point of view of the program's operation, each time a Java object is created, it allocates memory space for the instance variable and
Initialization of the row.
A program can Initialize instance variables in 3 places :
. specifying an initial value when defining an instance variable ;
. specifying an initial value for an instance variable in a non-static initialization block ;
. When an instance variable specifies an initial value in the constructor .
Whenever a program invokes a specified constructor to create a Java Object, the constructor is bound to get an opportunity to execute. In addition, the non-static initialization blocks contained in the class are given an opportunity to execute and are always executed before the constructor executes.
The effect is as follows:
The initialization time of the variable of Java Foundation