Saturday 2 December 2017

Sort Tree map in descending order.

descendingMap() method is used to return a reverse order view of the mappings contained in this map.
import java.util.*;
public class TreeMapDemo
{ public static void main(String[] args)
{
TreeMap<Integer, String> treemap = new TreeMap<Integer, String>();
  treemap.put(2, "two");
treemap.put(1, "one");
treemap.put(3, "three");
treemap.put(6, "six");
treemap.put(5, "five");
Navigable map nmap=treemap.descendingMap();
  System.out.println(nmap); } }



No comments:

Post a Comment