Martin spotted a

few inconsistencies in the new Generic Collections
and wonders why…

But a couple of aspects of the new generics-enabled collections framework
annoy me. For example, the Collections interface is declared as
Collection<E> and the
add method, for example, is
correctly declared as:
    boolean add(E object)
So I cannot help but wonder why, then, is
remove declared as:
    boolean remove(Object object)


Similarly, the toArray() method should be declared as follows:
    E[] toArray()
Instead of:
    Object[] toArray()

Rest assured, this is not an oversight, these methods were designed this way
for two very good reasons.

Can you see why?

Here are hints if you get stumped (in white):

  1. Existing 1.4 code would break with this definition.
  2. Try to implement this method for all Collections.