Talking about the Javase memory flowchart and the javase Flowchart
Recently I have been familiar with OOP object-oriented and have learned OOP, this, super, package, extends, and override. If we do not know the memory process, we will be confused about this knowledge, with the help of a teacher, I took a picture to clearly mark the process of the Code in the memory.
Memory is roughly divided into four areas: 1. Static Data Zone 2. Stack 3. Heap 4. Static Data Zone
Coding, compilation, calling and running, loading Jvm will not be detailed. Everyone should be clear about it.
The code first opens up space and names in the static code segment, then the method opens up space in the stack memory, opens space in the memory, and copies the corresponding classes to the heap memory, assign values and perform constructor code operations. Finally, copy the object address in heap memory to the corresponding class variable.
Sample Code:
public class OOP_05{ public static void main(String[] args){ Animal a = new Animal(10); m_1(a); System.out.println( "main----->" + a.age ); System.out.println( a ); } public static void m_1(Animal a){ a.age++; System.out.println( "m_1 --->" + a.age ); }}class Animal{ //Field int age; //Constructor Animal(int _age){ age = _age; }}
When figuring out the process, you must first understand the composition of the class: roughly divided into nine categories, 1. Entry Method 2, static variable 3, static method 4, member variable 5, member Method 6, construction method 7, static code segment 8, member code segment 9, abstract Method
You must know that the data in the memory cannot be accessed across domains. Otherwise, an error is reported. The static method cannot call non-static methods.
Stack frames must be opened before calling the method.