how to get last value from TreeMap in java code example
Example: TreeMap lastEntry() method in java
import java.util.TreeMap;
public class TreeMapLastEntryMethodExample
{
public static void main(String[] args)
{
TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
tm.put(96, "mango");
tm.put(39, "grapes");
tm.put(56, "pineapple");
tm.put(93, "apple");
tm.put(69, "watermelon");
System.out.println("Check last entry in given TreeMap: ");
System.out.println("Value is: "+ tm.lastEntry());
}
}