Possible Duplicate:
IsList<Dog>
a subclass ofList<Animal>
? Why aren't Java's generics implicitly polymorphic?
I have this code:
ArrayList<A> objects = new ArrayList<A>();
objects.add(new B());
where B
is a child class o A
. It gives me a compile time error like so:
The method add(A) in the type ArrayList is not applicable for the arguments (B)