Check out example codes for "TreeMap keySet() method in java". It will help you in understanding the concepts better.

Code Example 1

import java.util.TreeMap;
public class TreeMapKeySetMethodExample
{
   public static void main(String[] args)
   {
      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
      tm.put(53, "mango");
      tm.put(62, "apple");
      tm.put(29, "grapes");
      tm.put(93, "banana");
      tm.put(98, "watermelon");
      System.out.println("Given TreeMap is: " + tm);
      // use keySet() to get set view of keys
      System.out.println("set is: " + tm.keySet());
   }
}

Learn ReactJs, React Native from akashmittal.com