一:概述
在相关文章前面说明了一下一个对象的内存图,在这里将继续说明两个对象的内存图。
二:具体说明
<1>实例代码Student类
public class Student {
String name;
int age;
String address;
public void study(){
System.out.println(name + "天天运动");
}
实例代码StudentTest2类
public static void main(String[] args) {
Student s1 = new Student();
System.out.println(s1);
s1.name = "小明";
s1.age = 23;
s1.address = "上海";
System.out.println(s1.name + "..." + s1.age + "..." + s1.address);
s1.study();
Student s2 = new Student();
System.out.println(s2);
s2.name = "小亮";
s2.age = 21;
s2.address = "广东";
System.out.println(s2.name + "...." + s1.age + "..." + s2.address);
s2.study();
}
<2>测试结果截图
<3>内存图的绘制
标签:java,name,s2,s1,System,面向对象,内存,Student,out From: https://blog.51cto.com/u_15912723/9337823