PPT Slide
- used here to give an object of a superclass the form of the appropriate subclass, e.g.,
if (animalArray[iIndex] instanceof Dog)
animalArray[iIndex].bark();
would produce an error because objects of class Animal have no method called bark. So, we first cast what instanceof tells us is a Dog as a Dog.
if (animalArray[iIndex] instanceof Dog)
d = (Dog) animalArray[iIndex]