java中,调用不同类属性,将Computer类中brand属性调到了Study类中的comp属性中为什么写
stu.comp=c1
不能为stu.comp;=c1.brand;
public class Study {
//属性fields
int id;
String sname;
int age;
Computer comp;//计算机
Computer ren;
//方法
void study() {
System.out.println("我正在学习,使用的电脑:"+comp.brand);
}
void play() {
System.out.println("我在玩游戏,看手机浪费生命!");
}
//构造方法。用于创建这个类的对象。无参的构造方法可以由系统自动创建。
Study(){
}
//程序执行的入口,必须要有
public static void main(String[] args) {
Study stu=new Study();//创建一个对象(Study调用了Study类的构造方法,这个方法系统自动创建的)
stu.id=1;
Computer c1 = new Computer();
c1.brand="dell ";
stu.comp=c1;
stu.play(); 
stu.study();
}

class Computer{
String brand;
}