Q:

Java Program to copy a Tree Map content to another Tree Map

0

Program to copy a Tree Map content to another Tree Map.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.*;  
public class demo1 
{  
 public static void main(String args[])
 {  
   TreeMap<Integer,String> treemap1=new TreeMap<Integer,String>();      
   treemap1.put(1, "C#");
   treemap1.put(2, "C++");
   treemap1.put(3, "Java");
   System.out.println("Elements in Tree Map1 are: "+treemap1);
  
   TreeMap<Integer,String> treemap2=new TreeMap<Integer,String>();  
   treemap2.put(4, "Python");
   treemap2.put(5, "Perl");
   System.out.println("Elements in Tree Map2 are: "+treemap2);
    
   treemap1.putAll(treemap2);
   System.out.println("After coping map2 to map1: "+treemap1);   
 }  
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now