首页 > 系统相关 >创建对象内存分析

创建对象内存分析

时间:2022-11-17 20:01:09浏览次数:43  
标签:分析 System Pet dog 创建对象 内存 public out

创建对象内存分析

package com.oop.demo03;

public class Pet {
    public String name;
    public int age;

    public void shout(){
        System.out.println("叫了一声");
    }
}

package com.oop;
import com.oop.demo03.Pet;
public class Application {
    public static void main(String[] args) {
        Pet dog = new Pet();
        dog.name = "旺财";
        dog.age = 6;
        dog.shout();

        System.out.println(dog.name);
        System.out.println(dog.age);

        Pet cat = new Pet();
    }
}

标签:分析,System,Pet,dog,创建对象,内存,public,out
From: https://www.cnblogs.com/wangzhizhi/p/16900605.html

相关文章