Get last entry from NavigableMap in Java

import java.util.*;
public class Demo {
   public static void main(String[] args) {
      NavigableMap<String, Integer> n = new TreeMap<String, Integer>();
		n.put("A", 498);
		n.put("B", 389);
		n.put("C", 868);
		n.put("D", 988);
		n.put("E", 686);
		n.put("F", 888);
		n.put("G", 999);
		n.put("H", 444);
		n.put("I", 555);
		n.put("J", 666);
		System.out.println("NavigableMap elements...\n"+n);
		System.out.println("Last Entry is "+n.lastEntry());


We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.