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