Introduction to OOP | Chapter 18: Generics : | next | previous | audio | real | text |
BoyChild [ ] boys = new BoyChild[10]; Person [ ] people = boys; // copy or pointer semantics? GirlChild sally = new GirlChild; people[1] = sally;If pointer semantics are used for the array assignment then this can produce type errors. Java allows the assignment, but uses a run-time check to catch the last assignment error!
Other languages make the array assignment illegal.