public class Student {
int score;
int age;
String name;
Computer computer;
public void study() {
System.out.println("studying...");
}
}
public class Computer {
int price;
String brand;
}public class Test {
public static void main(String[] args) {
Student stu = new Student();
stu.name = "xiaoming";
stu.age = 10;
stu.study();
Computer c = new Computer();
c.brand = "Hasse";
System.out.println(c.brand);
stu.computer = c;
System.out.println(stu.computer.brand);
// System.out.println("----------------------------------------");
//
// c.brand = "Dell";
//
// System.out.println(c.brand);
// System.out.println(stu.computer.brand);
//
// System.out.println(stu.computer.brand == c.brand);
}
}
20171114103423173.png (122.7 KB, 下载次数: 26)
20171114103931438.png (132.59 KB, 下载次数: 13)
20171114102224911 (1).png (116.39 KB, 下载次数: 21)
| 欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |