Possible Duplicate:
Why aren't Java Collections remove methods generic?
I noticed that few of the LinkedList operations take Generic parameter type E, while a few take ‘Object’ as the parameter. For ex,
add(E e)
remove(Object o)
Is there a specific reason to do that? Why not make ‘remove’ take a generic type E. (I know it doesn’t matter after type erasure, but just wondering).
Both the add and remove methods are inherited from the Collection interface. The remove method was not retrofitted with a generic argument presumably because it wouldn’t matter. Remove doesn’t affect the type safety of the collection and when you’re changing one of the most popular APIs on the planet, fewer changes are better. You’ll see that the contains method suffered the same fate as well.