Hi I\'m wondering if there is a simple solution to my problem,
I have an ArrayList
:
ArrayList animalList = new
You dont need to do any casting. The overridden method should get called [simple polymorphism]
Animal aAnimal== this.animalList.get(animalIndex);
aAnimal.move();
Above code should call bird method if object is of bird, isn't it?
And casting is not a solution , how will you decide which object to cast? You will have to use instanceOf.