Introduction to OOP | Chapter 18: Generics : | next | previous | audio | real | text |
Unfortunately, runs into problems with the principle of substitution.
Assume Box[BoyChild] is a subclass of Box[Person], would make the following legal:
Box[Person] aBox = new Box[BoyChild]; Person aGirl = new GirlChild; aBox.set(aGirl);A similar argument can be made for the reverse.