public class Test2 {
/**
* @param args
*/
public static void main(String[] args) {
Test2 test2=new Test2();
Animal a=new Animal("name");
Cat c =new Cat("catname", "blue");
Dog d=new Dog("dogname", "black");
test2.f(a);
test2.f(c);
test2.f(d);
}
public void f(Animal a){
System.out.println("name:"+a.name);
if(a instanceof Cat){
Cat cat=(Cat)a;
System.out.println(" "+cat.eyeColor+"eyes");
}else if(a instanceof Dog){
Dog dog=(Dog)a;
System.out.println(" "+dog.furColor+"fur");
}
}
}