ArrayList containing different objects of the same superclass - how to access method of a subclass
问题 Hi I'm wondering if there is a simple solution to my problem, I have an ArrayList : ArrayList <Animal> animalList = new ArrayList<Animal>(); /* I add some objects from subclasses of Animal */ animalList.add(new Reptile()); animalList.add(new Bird()); animalList.add(new Amphibian()); They all implement a method move() - The Bird flies when move() is called. I know I can access common methods and properties of the super class by using this public void feed(Integer animalIndex) { Animal aAnimal