class Animal {}
class Horse extends Animal {}
class UseAnimals {
public void doStuff(Animal a) {
System.out.println("In the Animal version");
}
public void doStuff(Horse h) {
System.out.println("In the Horse version");
}
public static void main(String[] args) {
UseAnimals ua = new UseAnimals();
Animal animalObj = new Animal();
Horse horseObj = new Horse();
ua.doStuff(animalObj);
ua.doStuff(horseObj);
}
}
我编写了上面的示例代码并试图在我的eclipse上运行它,但我只能获得在服务器上运行它的选项。我无法作为Java应用程序运行。 文件名是Test1.java