fork download
  1.  
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class MyTreeMapCopy {
  8. public static void main(String a[]){
  9. TreeMap<String, String> hm = new TreeMap<String, String>();
  10. hm.put("first", "FIRST INSERTED");
  11. hm.put("second", "SECOND INSERTED");
  12. hm.put("third","THIRD INSERTED");
  13. System.out.println(hm);
  14. TreeMap<String, String> subMap = new TreeMap<String, String>();
  15. subMap.put("s1", "S1 VALUE");
  16. subMap.put("s2", "S2 VALUE");
  17. hm.putAll(subMap);
  18. System.out.println(hm);
  19. }
  20. }
Success #stdin #stdout 0.06s 3359744KB
stdin
Standard input is empty
stdout
{first=FIRST INSERTED, second=SECOND INSERTED, third=THIRD INSERTED}
{first=FIRST INSERTED, s1=S1 VALUE, s2=S2 VALUE, second=SECOND INSERTED, third=THIRD INSERTED}