treemap submap 28k fromkey k tokey 29 method in java

Solutions on MaxInterview for treemap submap 28k fromkey k tokey 29 method in java by the best coders in the world

showing results for - "treemap submap 28k fromkey k tokey 29 method in java"
Valentín
13 Sep 2016
1import java.util.NavigableMap;
2import java.util.TreeMap;
3public class TreeMapSubMapMethodExample
4{
5   public static void main(String[] args)
6   {
7      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
8      NavigableMap<Integer, String> nm = new TreeMap<Integer, String>();
9      tm.put(18, "violet");
10      tm.put(12, "red");
11      tm.put(14, "violet");
12      tm.put(16, "green");
13      tm.put(20, "blue");
14      System.out.println("Get a portion of TreeMap: ");
15      nm = tm.subMap(12, true, 18, true);
16      System.out.println("Sub map values are: " + nm);
17   }
18}
Eugénie
14 Jul 2019
1import java.util.SortedMap;
2import java.util.TreeMap;
3public class TreeMapSubMapFromKeyMethodExample
4{
5   public static void main(String[] args)
6   {
7      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
8      SortedMap<Integer, String> sm = new TreeMap<Integer, String>();
9      tm.put(18, "violet");
10      tm.put(12, "red");
11      tm.put(14, "violet");
12      tm.put(16, "green");
13      tm.put(20, "blue");
14      System.out.println("Gett a portion of TreeMap: ");
15      sm = tm.subMap(12, 18);
16      System.out.println("Sub map values are: " + sm);
17   }
18}