Answers for "TreeMap tailMap(K fromKey) method in java"

2

TreeMap tailMap(K fromKey) method in java

import java.util.SortedMap;
import java.util.TreeMap;
public class TreeMapTailMapMethodExample
{
   public static void main(String[] args)
   {
      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
      SortedMap<Integer, String> sm = new TreeMap<Integer, String>();
      tm.put(18, "violet");
      tm.put(12, "red");
      tm.put(14, "violet");
      tm.put(16, "green");
      tm.put(20, "blue");
      System.out.println("Get tail map of TreeMap: ");
      sm = tm.tailMap(14);
      System.out.println("Tail map values are: " + sm);
   }
}
Posted by: Guest on October-28-2020

Code answers related to "TreeMap tailMap(K fromKey) method in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language