java吧 关注:1,257,871贴子:12,752,495
  • 1回复贴,共1

JAVA代码运行出错

只看楼主收藏回复


package xiaohu;
class Grain{
public String toString(){
return "Grain";
}
}
class Wheat extends Grain{
public String toString(){
return "Wheat";
}
}
class Mill{
Grain process(){
return new Grain();
}
}
class WheatMill extends Mill{
Wheat process(){
return new Wheat();
}
}
public class One {
public static void main(String[] args) {
Mill m=new Mill();
Grain g=m.process();
System.out.print(g);
m=new WheatMill();
g=m.process();
System.out.print(g);
}
}
这段:class WheatMill extends Mill{
Wheat process(){
return new Wheat();
}
}
说不兼容,怎么回事?


1楼2011-09-16 09:50回复
    mark


    来自掌上百度2楼2011-09-16 10:12
    回复