private ArrayList<HashSet<Integer>> sets = new ArrayList<HashSet<Integer>>();
Iterator i = this.sets.iterator();
while (i.hasNext()){
if(i.next().containsAll(union)){
return true;
}
}
我得到它asssumes的.next()以下異常得到Object類型迭代器應該返回HashSet的,但作爲對象
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Type mismatch: cannot convert from Object to HashSet<Integer>
The method containsAll(HashSet<Integer>) is undefined for the type Object
的對象雖然我得到的對象哈希集合
while (i.hasNext()){
System.out.println(i.next().getClass().getName());
}
打印
java.util.HashSet
java.util.HashSet
java.util.HashSet
去什麼在?上?
getName()方法將返回類的名稱。這裏的類名是java.util.HashSet – Achilles 2012-08-14 04:52:49