- HashSet的使用
1. HashSet存储字符串并遍历
HashSet<String> hs = new HashSet<>();
boolean b1 = hs.add("a");
boolean b2 = hs.add("a");
System.out.println(b1);
System.out.println(b2);
for(String s : hs) {
System.out.println(s);
}
1. HashSet存储字符串并遍历
HashSet<String> hs = new HashSet<>();
boolean b1 = hs.add("a");
boolean b2 = hs.add("a");
System.out.println(b1);
System.out.println(b2);
for(String s : hs) {
System.out.println(s);
}