大家帮忙检查一下错在那里
class Animal {int id = 0;
int color = 0;
public void setId(int id){
this.id = id;
}
public void setColor(int color) {
this.color = color;
}
public int getId() {
return id;
}
public int getColor() {
return color;
}
}
class dog extends Animal {
int age = 0;
public void setAge(int age) {
this.age = age;
}
public int getAge() {
return age;
}
}
public class Dogs{
public static void main(String[] args) {
dog m = new dog();
dog.setId(10001);
dog.setColor(231);
dog.setAge(2);
System.out.println("M ID:" + m.getId());
System.out.println("M color:" + m.getColor());
System.out.println("M Age:" + m.getAge());
}
}
——————————————————————————
编译的时候会出现“无法从静态上下文中应用非静态……”。