Originally posted by Jae Stryker:
The problem is as the other guys said - You've declared an ArrayList of Middles and are trying to add a object type of Top to it, which does fit the IS-A structure i.e. Top is not a Middle - though Middle is a Top so if you were to change your code to
it would compile.
This question often causes me confusion.
Here is an extract that i found out in a website.
So even though "? super T" is a lower bound,it depends on final instatntiation of reference
Ex:
List <? super Top> list = new ArrayList <Top> ();
Even though the above code says,List can take any objects of Top anmd Super types,you can only add objects of Top and Subtypes..
Am i right?
Can anyone explain it bit more
Many Thanks