How to get the lowest Key stored in TreeMap
Previous | Home | Next |
This example shows how to get the lowest or first key from the TreeMap.
firstkey() method of TreeMap class is used to get the first or lowest key of the TreeMap.
firstkey() method of TreeMap class is used to get the first or lowest key of the TreeMap.
firstkey() method of TreeMap class is used to get the first or lowest key of the TreeMap.
package Example;
import java . util.TreeMap;
public class TreeMapExample {
public static void main(String[] args) {
TreeMap tmp= new TreeMap();
tmp.put("one", new Integer(1) );
tmp.put("Two", new Integer(2));
tmp.put("Three", new Integer(3));
tmp.put("four", new Integer(4));
tmp.put("five", new Integer(5));
System.out.println("Lowest key Stored in TreeMap is :" + tmp.firstKey());
// TODO Auto-generated method stub
}
}
Previous | Home | Next |