Community
Participate
Working Groups
if i have an object declared as: Set<MyClass> mySet = new HashSet<MyClass>(); then i should NOT be able to do: mySet.toArray(new AnotherClass[1]); but the 3.1.0 JDT compiler (Build id: 200408122000) doesn't complain. this seems like a compilation bug! 'AnotherClass' and 'MyClass' are in separate object hierarchies.
Cannot reproduce in latest. import java.util.HashSet; import java.util.Set; public class X { public static void main(String[] args) { Set<X> mySet = new HashSet<X>(); mySet.toArray(""); } } ---------- 1. ERROR in X.java (at line 8) mySet.toArray(""); ^^^^^^^ The method toArray() in the type Set<X> is not applicable for the arguments (String) ----------