treemap clear 28 29 method in java

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

showing results for - "treemap clear 28 29 method in java"
Jan
19 Nov 2017
1import java.util.TreeMap;
2public class TreeMapClearMethodExample
3{
4   public static void main(String[] args)
5   {
6      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
7      tm.put(8, "red");
8      tm.put(12, "blue");
9      tm.put(10, "yellow");
10      tm.put(6, "green");
11      tm.put(4, "violet");
12      System.out.println("TreeMap before using clear() method: " + tm);
13      // clearing TreeMap using clear() method
14      tm.clear();
15      System.out.println("TreeMap after using clear() method: " + tm);
16   }
17}