treemap remove 28object key 29 method in java

Solutions on MaxInterview for treemap remove 28object key 29 method in java by the best coders in the world

showing results for - "treemap remove 28object key 29 method in java"
Lila
06 Jan 2021
1import java.util.TreeMap;
2public class TreeMapRemoveMethodExample
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      System.out.println("Given TreeMap is: " + tm);
13      // remove existing key mapping
14      String strReturn = (String)tm.remove(38);
15      System.out.println("Returned value is: " + strReturn);
16      System.out.println("New TreeMap is: " + tm);
17   }
18}