PPT Slide
if (animalArray[iIndex] instanceof Dog) {
animalArray[iIndex].bark;
- 2nd line isn’t (unless array has Dog).
- We can see that 1st line guarantees 2nd is legal.
- Compiler cannot see inter-statement dependencies… unless compiler runs whole program with all possible data sets!
- Runtime system could tell easily. We
want most checking at compile-time for
performance and correctness.