java习_2
关于java运行和内存变化机制
案例:
package p65_Student;
public class Student {
int id;
String name;
int age;
Computer comp;
//方法
void study(){
System.out.println("我在认真学习!!,使用电脑"+comp.brand);
}
Student(){
}
public static void main(String[]args){
Student stu = new Student();
stu.id=1001;
stu.name="高老师";
stu.age=18;
Computer c1 = new Computer();
c1.brand = "联想";
stu.comp = c1;
stu.study();
}
static class Computer{
String brand;
}
}
内存变化图: