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).
This is because removal operation checks for equality using equals()
method and equals()
method takes in an Object as parameter not generic .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With