treemap descendingkeyset 28 29 method in java

Solutions on MaxInterview for treemap descendingkeyset 28 29 method in java by the best coders in the world

showing results for - "treemap descendingkeyset 28 29 method in java"
Kelya
13 Mar 2016
1import java.util.NavigableSet;
2import java.util.TreeMap;
3public class TreeMapDescendingKeySetMethodExample
4{
5   public static void main(String[] args)
6   {
7      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
8      tm.put(63, "banana");
9      tm.put(56, "watermelon");
10      tm.put(35, "orange");
11      tm.put(83, "apple");
12      tm.put(65, "pineapple");
13      // put values in NavigableSet
14      NavigableSet ns = tm.descendingKeySet();
15      System.out.println("TreeMap values using descendingKeySet() method: ");
16      System.out.println("NavigableSet values: " + ns);
17   }
18}
Serena
20 Nov 2017
1import java.util.NavigableMap;
2import java.util.TreeMap;
3public class TreeMapDescendingMapMethodExample
4{
5   public static void main(String[] args)
6   {
7      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
8      tm.put(93, "blue");
9      tm.put(26, "violet");
10      tm.put(63, "red");
11      tm.put(53, "green");
12      tm.put(96, "five");
13      // put values in NavigableMap
14      NavigableMap nm = tm.descendingMap();
15      System.out.println("TreeMap values using descendingMap() method: ");
16      System.out.println("NavigableMap values: " + nm);
17   }
18}