抽象类的相关问题
import java.util.*;public abstract class Animal {
private String name;
abstract void showInfo();
abstract void act();
}
public class Cat extends Animal {
void showInfo(){
System.out.println("我是一只猫,");
}
void act(){
System.out.println("我将表演猫步");
}
}
public abstract class Dog extends Animal{
void showInfo(){
System.out.println("我是一只狗");
}
void act(){
System.out.println("我将表演双脚站立行走!");
}
}
public abstract class Bird extends Animal {
void showInfo(){
System.out.println("我是一只鸟");
}
void act(){
System.out.println("我将表演唱歌");
}
}
public class zoo {
public static void main(String[] args) {
Cat cat1 =new Cat();
Bird bird1 =new Bird();//Cannot instantiate the type Bird
Dog dog1=new Dog();//Cannot instantiate the type Dog
}
}
为什么注释的两行,会出来后面的错误?