请教一个Java初学者的问题!
编译提示
I:\workspace\java\MyGame\RobLord\test.java:10: non-static method MyGod() cannot be referenced from a static context
是面向对象没有学好,请高手讲讲。
public class test{
static void main (String[] arg){
Plan Wife,God;
Wife = new Plan("");
Wife.prt();
Wife = MyGod();
//负值
God = Wife;
God.prt();
//修改
God.name = "god plan";
System.out.println("修改后");
God.prt();
Wife.prt();
}
public Plan MyGod(){
return new Plan("huyang-->2");
}
}
class Plan{
String name;
Plan(String name){
this.name = name;
}
public void prt(){
System.out.println(this.name);
}
}