package notebook;
import java.util.HashSet;
public class NoteBook{
public static void main(String[] args){
HashSet<String> s =new HashSet<String>();
s.add("first");
s.add("second");
s.add("third");
s.add("second");
s.add("third");
for(String k : s) {
System.out.println(k);
}
//System.out.println(s); // 也能直接遍历打印
}
}
结果:
third
first
second