Day009 创建对象内存分析
作者:互联网
创建对象内存分析
public class Pet {
public String name;
public int age;
public void shout(){
System.out.println("叫了一声");
}
}
public class Application {
public static void main(String[] args) {
Pet dog = new Pet();
dog.name="旺财";
dog.age=3;
dog.shout();
System.out.println(dog.name);
System.out.println(dog.age);
Pet cat=new Pet();
}
}
输出结果
叫了一声
旺财
3
内存分析图
标签:System,name,Pet,dog,创建对象,内存,out,public,Day009 来源: https://www.cnblogs.com/dwystudy/p/14748505.html