Java Collection Tutorial - Java NavigableMap.tailMap(K fromKey, boolean inclusive)








Syntax

NavigableMap.tailMap(K fromKey, boolean inclusive) has the following syntax.

NavigableMap < K , V > tailMap(K fromKey,   boolean inclusive)

Example

In the following code shows how to use NavigableMap.tailMap(K fromKey, boolean inclusive) method.

// ww  w. ja  va  2  s  .  c  om

import java.util.NavigableMap;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    NavigableMap<Integer, String> map = new TreeMap<Integer, String>();
    map.put(2, "two");
    map.put(1, "one");
    map.put(3, "three");
    System.out.println( map.tailMap(1,true) + "\n");


  }
}

The code above generates the following result.