Person p = new Person();What does it do in memory?
Load the Person.class file into memory.
If p is defined in the main method, then a variable space p will be opened in the stack space.
Allocate space for objects in heap memory.
Perform default initialization of members in the object.
Perform explicit initialization of members in the object.
Call the construction code block to initialize the object. (If not, it will not be executed)
Call the constructor to initialize the object. The object is initialized.
Assign the memory address of the object to the p variable and let the p variable point to the object.
The above is the detailed content of Person p = new Person(); What does it do in memory?. For more information, please follow other related articles on the PHP Chinese website!