treemap putall 28 29 method in java

Solutions on MaxInterview for treemap putall 28 29 method in java by the best coders in the world

showing results for - "treemap putall 28 29 method in java"
Claudio
22 Jan 2017
1import java.util.TreeMap;
2public class TreeMapPutAllMethodExample
3{
4   public static void main(String[] args)
5   {
6      TreeMap<Integer, String> tm1 = new TreeMap<Integer, String>();
7      tm1.put(32, "pineapple");
8      tm1.put(51, "watermelon");
9      tm1.put(38, "grapes");
10      tm1.put(69, "mango");
11      tm1.put(58, "apple");
12      System.out.println("TreeMap before using putAll() method: " + tm1);
13      // create new TreeMap and copy
14      TreeMap<Integer, String> tm2 = new TreeMap<Integer, String>();
15      tm2.putAll(tm1);
16      System.out.println("TreeMap after using putAll() method: " + tm2);
17   }
18}