Why does Java's Collection<E>.toArray() return an Object[] rather than an E[]?
Before Java generics, Collection.toArray() had no way to know which type of array the developer expected (particularly for an empty collection). As I understand it, this was the main rationale behind the idiom collection.toArray(new E[0]).

With generics, Collection<E>.toArray() can only return an array full of instances of E and/or its specialisations. I wonder why the return type still is as Object[] rather than E[]. In my opinion, returning an E[] instead of Object[] should not break existing code.

See:
http://download.oracle.com/javase/6/docs/api/java/util/Collection.html#toArray%28%29
and
http://download.oracle.com/javase/6/docs/api/java/util/Collection.html#toArray%28T%5b%5d%29
Why does Java's Collection<E>.toArray() return an Object[] rather than an E[]?
===

Before Java generics, Collection.toArray() had no way to know which type of array the developer expected (particularly for an empty collection). As I understand it, this was the main rationale behind the idiom collection.toArray(new E[0]).

With generics, Collection<E>.toArray() can only return an array full of instances of E and/or its specialisations. I wonder why the return type still is as Object[] rather than E[]. In my opinion, returning an E[] instead of Object[] should not break existing code.

See:
http://download.oracle.com/javase/6/docs/api/java/util/Collection.html#toArray%28%29
and
http://download.oracle.com/javase/6/docs/api/java/util/Collection.html#toArray%28T%5b%5d%29