Possible Duplicate:
Why aren't Java Collections remove methods generic?
Why is the signature of Collection.remove()
defined as follows:
public boolean remove(Object o)
and not
public boolean remove(E e)
where E is the type of collection.
We know if c
is a Collection
of type E
[Collection<E>
] then c
will always contain objects of E
or sub classes of E
. Then why don't we restrict the method parameter to either E
or ? extends E