package MyPro004;
/**
*
*
* @author
*
*/
public class Student {
//属性
int id;
String name;
int age;
Computer comp;
//方法
void play() {
System.out.println("我在玩游戏,王者荣耀!!");
}
void study() {
System.out.println("我在认真学习!!"+ comp.brand);
}
Student(){ //构造方法,用于创建这个类的对象,无参的构造方法可以由系统自动创建
}
//static Student a = new Student();
public static void main(String[] args) {
Student a = new Student();
a.id = 1001;
a.name = "高淇的Java课";
a.age = 18;
Computer c1 = new Computer();
c1.brand = "联想";
a.comp = c1;
a.play();
a.study();
}
}
class Computer {
String brand;
}