treemap put 28 29 method in java

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

showing results for - "treemap put 28 29 method in java"
Brenton
11 Jan 2017
1import java.util.TreeMap;
2public class TreeMapPutMethodExample
3{
4   public static void main(String[] args)
5   {
6      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
7      tm.put(32, "pineapple");
8      tm.put(51, "watermelon");
9      tm.put(38, "grapes");
10      tm.put(69, "mango");
11      tm.put(58, "apple");
12      // put value at key 3
13      System.out.println("TreeMap before using put(K key, V value) method: " + tm);
14      System.out.println("Value is: " + tm.put(38, "banana"));
15      System.out.println("TreeMap after using put(K key, V value) method: " + tm);
16   }
17}