I have a basic question regarding assignment of a list of subclass to a list of superclass.
So I have something like the following:
Class B extends
While at first glance you might think that
Class B extends A;
List bList = new ArrayList();
List aList = bList;
should work, the problem is obvious when you imagine actually using these lists:
A something = new A();
aList.add( something ); // Should work because aList is a list of A's
but aList was assigned to bList, so that should be the same as
bList.add( something ); // Here's the problem
bList.add() takes a B, but something is an A, and an A is not a B!
And that's why generics should be (and are) strict type safe.