Talking about javase memory flowchart

Source: Internet
Author: User

Recently contacted OOP object-oriented, learning OOP, this, super, package, extends and override, overall if not clear memory of the process, the knowledge will be very confusing, with the teacher's help, took a picture, Can clearly identify the process of code in memory

Memory is roughly divided into four regions: 1, static data area 2, Stack 3, heap 4, static data area

Coding, compiling, calling to run, loading the JVM is not a detail, everyone should be clear.

The code first opens up space and name in the static code segment, then approaches and opens up space in the stack memory, opens up space in memory, copies the corresponding class into the heap memory, assigns values to the code operations of the constructor, and finally copies the addresses of the objects in the heap memory to the corresponding class variables.

Specific example code:

public class oop_05{public    static void Main (string[] args) {        Animal a = new Animal (ten);        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;    }}

To understand the process, you must first know what the composition of the class is: roughly divided into nine classes, 1, the Entry Method 2, the static variable 3, the static method 4, the member variable 5, the member method 6, the construction method 7, the static code segment 8, the member code segment 9, the abstract method

You should know that in-memory data cannot be accessed across domains, or you will get an error, static methods cannot call non-static methods

The calling method must first open the stack frame

Talking about javase memory flowchart

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.