Slide 7
Slide 7 text
Invariance
Why?
List strs = new ArrayList();
List objs = strs; // !!! The cause of the upcoming
problem sits here. Java prohibits this!
objs.add(1); // Here we put an Integer into a list of Strings
String s = strs.get(0); // !!! ClassCastException: Cannot cast
Integer to String
Note: All generic types in Java are invariant!