Why isn\'t Collection.remove(Object o) generic?
Seems like Collection
could have boolean remove(E o);
Then, when you ac
It was a compromise. Both approaches have their advantage:
remove(Object o)
remove(E e)
brings more type safety to what most programs want to do by detecting subtle bugs at compile time, like mistakenly trying to remove an integer from a list of shorts.Backwards compatibility was always a major goal when evolving the Java API, therefore remove(Object o) was chosen because it made generifying existing code easier. If backwards compatibility had NOT been an issue, I'm guessing the designers would have chosen remove(E e).