TreeMap lastKey() method in java
map integer values to string keys
import java.util.TreeMap;
public class TreeMapLastKeyMethodExample
{
public static void main(String[] args)
{
TreeMap<String, Integer> tm = new TreeMap<String, Integer>();
tm.put("yellow", 99);
tm.put("violet", 86);
tm.put("red", 93);
tm.put("green", 36);
tm.put("blue", 29);
System.out.println("Given TreeMap is: " + tm);
// display lastKey of TreeMap
System.out.println("last key is: " + tm.lastKey());
}
}