How to get the highest value stored in TreeMap
Previous | Home | Next |
This program shows how to get the Highest key or Last key of the TreeMap.
lastkey() method of TreeMap class is used to get the Highest key from the TreeMap.
lastkey() method of TreeMap class is used to get the Highest key from the TreeMap.
lastkey() method of TreeMap class is used to get the Highest key from 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 |