import java.util.HashSet;输出:
public class HashSetremove{
public static void main(String[] args) {
HashSet<字符串>hashset = 新的 HashSet<字符串>();
hashset.add(v1”);
hashset.add(v2”);
hashset.add(v3”);
hashset.add(v4”);
hashset.add(v5”);
System.out.println(删除前的 HashSet: ”+hashset);
对象 e = v2”;
布尔值 b = hashset.remove(v2”);
System.out.println(删除了”+e+元素:”+b);
System.out.println(删除 ”+e+: ”+hashset) 后的 HashSet;
}
}
删除前的哈希集:[v1、v5、v4、v3、v2]
v2 删除项:true
删除 v2 后的哈希集:[v1、v5、v4、v3]
Please disable your ad blocker and refresh the window to use this website.