Check out example codes for "TreeMap put() method in java". It will help you in understanding the concepts better.

Code Example 1

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);
   }
}

Learn ReactJs, React Native from akashmittal.com