Answers for "TreeMap putAll() method in java"

1

TreeMap putAll() method in java

import java.util.TreeMap;
public class TreeMapPutAllMethodExample
{
   public static void main(String[] args)
   {
      TreeMap<Integer, String> tm1 = new TreeMap<Integer, String>();
      tm1.put(32, "pineapple");
      tm1.put(51, "watermelon");
      tm1.put(38, "grapes");
      tm1.put(69, "mango");
      tm1.put(58, "apple");
      System.out.println("TreeMap before using putAll() method: " + tm1);
      // create new TreeMap and copy
      TreeMap<Integer, String> tm2 = new TreeMap<Integer, String>();
      tm2.putAll(tm1);
      System.out.println("TreeMap after using putAll() method: " + tm2);
   }
}
Posted by: Guest on October-28-2020

Code answers related to "TreeMap putAll() method in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language