首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

在eclipse中写的代码有错,但在dos中可以运作,为什么

2012-10-07 
在eclipse中写的代码有错,但在dos中可以运行,为什么?abstractclass Animal//(1){String nameabstract voi

在eclipse中写的代码有错,但在dos中可以运行,为什么?
abstract class Animal //(1)
{

String name;
abstract void go();
}
class Cat extends Animal
{
Cat(String name){
this.name=name;
}
public void go()
{
System.out.println(name+" can run.");
}
}
class Bird extends Animal
{
Bird(String name){
this.name=name;
}
public void go()
{
System.out.println(name+" can fly.");
}

}
public class List141

public static void main(String[] args)
{
  Cat c=new Cat("Cady");
Bird b=new Bird("Bird");
c.go();
b.go();
}
}
在eclipse中(1)提示Animal已定义,运行有错,但在dos可以运行,为什么?

[解决办法]
eclipse中同一个包里的某个文件中已经定义过Animal类了
[解决办法]
同一个包下一句定义了Animal类了

热点排行