Answers for "TreeMap descendingKeySet() method in java"

2

TreeMap descendingKeySet() method in java

import java.util.NavigableSet;
import java.util.TreeMap;
public class TreeMapDescendingKeySetMethodExample
{
   public static void main(String[] args)
   {
      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
      tm.put(63, "banana");
      tm.put(56, "watermelon");
      tm.put(35, "orange");
      tm.put(83, "apple");
      tm.put(65, "pineapple");
      // put values in NavigableSet
      NavigableSet ns = tm.descendingKeySet();
      System.out.println("TreeMap values using descendingKeySet() method: ");
      System.out.println("NavigableSet values: " + ns);
   }
}
Posted by: Guest on October-28-2020
1

TreeMap descendingMap() method in java

import java.util.NavigableMap;
import java.util.TreeMap;
public class TreeMapDescendingMapMethodExample
{
   public static void main(String[] args)
   {
      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
      tm.put(93, "blue");
      tm.put(26, "violet");
      tm.put(63, "red");
      tm.put(53, "green");
      tm.put(96, "five");
      // put values in NavigableMap
      NavigableMap nm = tm.descendingMap();
      System.out.println("TreeMap values using descendingMap() method: ");
      System.out.println("NavigableMap values: " + nm);
   }
}
Posted by: Guest on October-28-2020

Code answers related to "TreeMap descendingKeySet() method in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language