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 iterator()hset.remove(1”);
Set4)Int size()hset = new HashSet ();
迭代器迭代器 = hset.iterator();
while(iterator.hasNext(){
String element = (String) iterator.next();
}
System.out.println(hset.size());
Set< 中插入的对象类型。字符串>set = 新 HashSet<字符串>();此语句仅接受 String 对象。优点是您可以使用并直接访问 Set 不带 cast:
for(String Object : set){References:
//做某事
}
Please disable your ad blocker and refresh the window to use this website.