Memory map of an object
Before running the main method, the method area first has data.
The methods area holds.class data, and the methods area holds information about the two.classes on the left.
Whoever has the main method starts, if the main method wants to run ahead of the stack, it enters the stack space.
I’m creating an object, and on the left side of the equals sign is a local variable, and the variable is just to hold something, and the new one is in the heap,
New is phone, the method area holds the phone information, put the member variable in the heap,
Now that we have member variables, what about member methods?
For an object, its member methods actually hold an address value. When you create an object, the address value of the phone. Class method in the method area will be saved to the heap.
New phone () has to have an address of its own,
To assign phone to one, place the address 0x666 in stack memory one,
Brand, one.price, one.color,null,0.0,null in the heap.
And then I’m going to change the value of the brand,
Find the member variable in heap memory based on the address, and then the value of the member variable.
And then there are two method calls,
Member methods are found in the heap memory based on red, and methods are found in the method area based on green.
I found a call method, and if I want to run the call method, I need to push it (also called pushing, because the last method is pushed on top of the first method).
When the call method completes and exits the stack, it pops out of the stack.