java.util · java.base · since Java 1.6

NavigableMap

declaration
public interface NavigableMap<K, V> extends SortedMap<K, V>

A SortedMap with nearest-match key/entry navigation and descending views. TreeMap is the standard implementation.

Key methods

K ceilingKey(K k) / floorKey(K k)Least key >= k / greatest key <= k (null if none).
K higherKey(K k) / lowerKey(K k)Strictly-greater / strictly-lesser key (null if none).
Map.Entry<K, V> ceilingEntry(K k) / floorEntry(K k)Nearest entry at or beyond / at or below k.
Map.Entry<K, V> firstEntry() / lastEntry()Extreme entries (null if empty).
Map.Entry<K, V> pollFirstEntry() / pollLastEntry()Retrieve and remove the extreme entry.
NavigableMap<K, V> descendingMap()Reverse-order view over the same mappings.
NavigableMap<K, V> subMap(K from, boolean fromInc, K to, boolean toInc)Key-range view with inclusive/exclusive endpoints.