private ArrayList<HashSet<Integer>> sets = new ArrayList<HashSet<Integer>>();
Iterator i = this.sets.iterator();
while (i.hasNext()){
if(i.next().containsAll(union)){
return true;
}
}
.next()がObject型のオブジェクトを取得すると想定しているため、次の例外が発生します
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
どうしたの ?