fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. HashMap<String,String>m=new HashMap<String,String>();
  13. m.put("first","first inserted");
  14. m.put("second","second inserted");
  15. m.put("third","third inserted");
  16. System.out.println("key value pairs are"+m);
  17. System.out.println(m.get("second"));
  18. System.out.println(m.isEmpty());
  19. System.out.println(m.size());
  20. Set keys=m.keySet();
  21. for(Object key:keys){
  22. System.out.println("value of" +key+ "is:"+m.get(key));
  23. }
  24.  
  25.  
  26. }
  27. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
key value pairs are{third=third inserted, first=first inserted, second=second inserted}
second inserted
false
3
value ofthirdis:third inserted
value offirstis:first inserted
value ofsecondis:second inserted