Community
Participate
Working Groups
in the java.util.Collection class, there is a method "<T> T[] toArray(T[] a)". the compiler doesn't seem to be checking for generic type conformance. example code SHOULD generate a compiler warning or error, but doesn't: Set<MyType> set = new HashSet<MyType>(); Object[] array = new Object[set.size()]; set.toArray(array);
Why would it generate an error ? FYI the following code also compiles ok with javac. import java.util.*; public class X { void foo() { Set<X> set = new HashSet<X>(); Object[] array = new Object[set.size()]; set.toArray(array); } }