This paper discusses the initialization time of the instance variable, and now the initialization time of the class variable.
The instance variable belongs to the Java class itself, and the class variables of that class are allocated memory space and initialized only when the program initializes the Java class.
From the point of view of the program running, each JVM is initialized only once for a Java class, so every time the Java program runs, the system allocates only one memory space for the class variable once and initializes it once. Fill in the picture abstract (optional)
The commented out code, if executed, runs a program of 3000.
If you put the code under the initial wage, the program runs at 5000?
Salary, the demo is first loaded by the class, in the main method by instantiating the object call Currentsalary, the static object s first assigns the value to Currentsalary 3000, and then Inisalary assigns the value, this time is 5000, The instance object is assigned to Addsalary, and the last currentsalary result is 6000.
Initialization time for variables like Java Foundation 09