fork download
  1.  
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class MyHashMapClear {
  8. public static void main(String a[]){
  9. HashMap<String, String> hm = new HashMap<String, String>();
  10. hm.put("first", "FIRST INSERTED");
  11. hm.put("second", "SECOND INSERTED");
  12. hm.put("third","THIRD INSERTED");
  13. System.out.println("My HashMap content:");
  14. System.out.println(hm);
  15. System.out.println("Clearing HashMap:");
  16. hm.clear();
  17. System.out.println("Content After clear:");
  18. System.out.println(hm);
  19. }
  20. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
My HashMap content:
{third=THIRD INSERTED, first=FIRST INSERTED, second=SECOND INSERTED}
Clearing HashMap:
Content After clear:
{}