fork download
  1.  
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class MyHashMapCopy {
  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. HashMap<String, String> subMap = new HashMap<String, String>();
  16. subMap.put("s1", "S1 VALUE");
  17. subMap.put("s2", "S2 VALUE");
  18. hm.putAll(subMap);
  19. System.out.println(hm);
  20. }
  21. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
{third=THIRD INSERTED, first=FIRST INSERTED, second=SECOND INSERTED}
{third=THIRD INSERTED, first=FIRST INSERTED, s1=S1 VALUE, second=SECOND INSERTED, s2=S2 VALUE}