Answers for "how to put sting in treemap"

1

TreeMap put() method in java

import java.util.TreeMap;
public class TreeMapPutMethodExample
{
   public static void main(String[] args)
   {
      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
      tm.put(32, "pineapple");
      tm.put(51, "watermelon");
      tm.put(38, "grapes");
      tm.put(69, "mango");
      tm.put(58, "apple");
      // put value at key 3
      System.out.println("TreeMap before using put(K key, V value) method: " + tm);
      System.out.println("Value is: " + tm.put(38, "banana"));
      System.out.println("TreeMap after using put(K key, V value) method: " + tm);
   }
}
Posted by: Guest on October-28-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language