public class Animal {
String name = "";
int age = 0;
public void printInfo() {}
}
public class Bird extends Animal {
String name = "红色的小小小鸟";
int age = 4;
public void printInfo() {
System.out.println("我是一只"+name);
System.out.println("我今年"+age+"岁了!");
}
}
public class Fish extends Animal{
String name = "5斤重的鱼";
int age = 2;
public void printInfo() {
System.out.println("我是一只"+name);
System.out.println("我今年"+age+"岁了!");
}
}
public class Test {
public static void main(String[] args) {
Animal b = new Bird();
b.printInfo();
Animal f = new Fish();
f.printInfo();
}
}