fork download
  1.  
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class MapKeys {
  8. public static void main(String a[]){
  9. HashMap<String, String> hm = new HashMap<String, String>();
  10. //add key-value pair to hashmap
  11. hm.put("first", "FIRST INSERTED");
  12. hm.put("second", "SECOND INSERTED");
  13. hm.put("third","THIRD INSERTED");
  14. System.out.println(hm);
  15. Set<String> keys = hm.keySet();
  16. for(String key: keys){
  17. System.out.println(key);
  18. }
  19. }
  20. }
Success #stdin #stdout 0.07s 3359744KB
stdin
Standard input is empty
stdout
{third=THIRD INSERTED, first=FIRST INSERTED, second=SECOND INSERTED}
third
first
second