fork(1) download
  1.  
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class MyBasicHashMap {
  8.  
  9. public static void main(String a[]){
  10. HashMap<String, String> hm = new HashMap<String, String>();
  11. hm.put("first", "FIRST INSERTED");
  12. hm.put("second", "SECOND INSERTED");
  13. hm.put("third","THIRD INSERTED");
  14. System.out.println(hm);
  15. System.out.println("Value of second: "+hm.get("second"));
  16. System.out.println("Is HashMap empty? "+hm.isEmpty());
  17. hm.remove("third");
  18. System.out.println(hm);
  19. System.out.println("Size of the HashMap: "+hm.size());
  20. }
  21. }
Success #stdin #stdout 0.06s 3359744KB
stdin
Standard input is empty
stdout
{third=THIRD INSERTED, first=FIRST INSERTED, second=SECOND INSERTED}
Value of second: SECOND INSERTED
Is HashMap empty? false
{first=FIRST INSERTED, second=SECOND INSERTED}
Size of the HashMap: 2