fork download
  1.  
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class MyHashSetRead {
  8.  
  9. public static void main(String a[]){
  10. HashSet<String> hs = new HashSet<String>();
  11. //add elements to HashSet
  12. hs.add("first");
  13. hs.add("second");
  14. hs.add("third");
  15. Iterator<String> itr = hs.iterator();
  16. while(itr.hasNext()){
  17. System.out.println(itr.next());
  18. }
  19. }
  20. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
third
first
second