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}