1import java.util.TreeMap;
2public class TreeMapKeySetMethodExample
3{
4 public static void main(String[] args)
5 {
6 TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
7 tm.put(53, "mango");
8 tm.put(62, "apple");
9 tm.put(29, "grapes");
10 tm.put(93, "banana");
11 tm.put(98, "watermelon");
12 System.out.println("Given TreeMap is: " + tm);
13 // use keySet() to get set view of keys
14 System.out.println("set is: " + tm.keySet());
15 }
16}