JavaseLearn19-JVM内存图

JavaseLearn19-JVM内存图

执行以下程序时JVM的内存图

/**
 * @Author: TSCCG
 * @Date: 2021/07/02 17:26
 */
public class JvmDemo01 {
    public static void main(String[] args) {
        int num = 10;
        Person person1 = new Person("张三",20);
        Person person2 = new Person();
        System.out.println(person1.getName() + " " + person1.getAge());
        System.out.println(person2.getName() + " " + person2.getAge());
    }
}
class Person {
    private String name;
    private int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
posted @ 2021-07-02 18:29  TSCCG  阅读(64)  评论(0编辑  收藏  举报