public void adda(List<? super c> ani)
{
ani.add((c)new Object());//or any of a,b, or c Objects
}
Regards,<br />George Gates
actually my code says the compiler that 'accept anything that is a super type of class 'c'. so it accepts class 'b'. so far good. but by no means i could add object of class 'a' (which is also a super type) to the list.(since only, the same type of subtype can be added to the list).whereas i have created the list for class 'b' type.
what will the compiler do when i add an object of class 'a' in the adda() method.???
Originally posted by Sumit Bisht:
A workaround to this problem is to cast the Object to be added into c
But I am still baffled by this behaviour
where does this subtype comes into picture??
Also, do you mean that adding an object of class 'a' is not legal??so it gives a compiler err??or exception???
// even i could not add b obj to my list..
Consider Paul's rocket mass heater. |