Set hset = new HashSet();
Set tset = new TreeSet();
Set lset = new LinkedHashSet();
Set hset = new HashSet();
hset.add(new String("1"));
hset.add(new String("2"));
3)イテレータ iterator()hset.remove("1");
Set4)Int size()hset = new HashSet ();
Iterator iterator = hset.iterator();
while(iterator.hasNext(){
文字列要素 = (文字列) iterator.next();
}
System.out.println(hset.size());
Setに挿入するオブジェクトのタイプを制限することは可能です<文字列>set = new HashSetです<文字列>();このステートメントは、String オブジェクトのみを受け入れます。利点は、Set without cast:
for(String Object : set){References:
//何かを
}
Please disable your ad blocker and refresh the window to use this website.