Possible Duplicate:
What are the reasons why Map.get(Object key) is not (fully) generic
This is similar to the question here, on java.util.Map. This question is left as a pointer to that question.
The List
interface contains several methods which still accept an Object as parameter, after generics were introduced in Java 5. Such as:
boolean contains(Object o)
int lastIndexOf(Object o)
boolean remove(Object o)
I was expecting these methods to make use of the type parameter. Something like this:
boolean contains(E e) // Where the interface is defined as List<E>
Although, it would have to be <? extends E>
, but I'm not sure of the syntax for that.
Is there a design reason why these methods take an Object, or is it for backwards bytecode compatibility, or is it another reason?