Talking about the Javase memory flowchart and the javase Flowchart

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.