Last update 30. January 2021.

NavigableMap in Java is an interface that is a sub-interface of the SortedMap interface. It extends the SortedMap interface to search for recordings based on the match between the case and one or more specific keys.

The NavigableMap interface was added in Java version 1.6. It is included in the java.util.NavigableMap package. The NavigableMap interface was recently added to the Java Collections Framework.

The TreeMap class is a widely used class that implements the NavigableMap interface in Java. The NavigableMap interface offers several ways to simplify map navigation.

Simply put, we can easily navigate the map using the NavigationMap interface. We can find the closest value that matches the specified key, all values that are lower than the specified key, all values that are higher than the specified key, and so on.

Hierarchy of the NavigableMap interface in Java

The interface NavigableMap extends the interfaces SortedMap and Map. The Java ConcurrentNavigableMap interface is a sub-interface of the NavigableMap interface.

The following figure shows a hierarchical diagram of the NavigableMap interface.

Explanation of NavigableMap interface

NavigableMap is a generic interface declared below:

The NavigableMap<K,V>
public interface extends SortedMap<K,V>.

Where K is the type of the keys and V is the type of the values corresponding to the keys.

In addition to the methods inherited from the SortedMap interface, the NavigableMap interface in Java also adds many new methods. They are as follows:

1. Card.Entrance<K,V> ceilingEntrance(K object) : This method looks for the smallest (smallest) key k in the directory such that the key k is greater than or equal to the specified key object (k >= obj).

If such a key is found, its entry is returned. If such a key is not found, a null object is returned.

2. K plafondKey(K obj) : This method searches the directory for the smallest key k such that the key k is greater than or equal to the specified key object (k >= obj).

If such a key is found, it will be returned. If such a key is not found, a null object is returned.

3. NavigableSet derivedKeySet() : This method returns the NavigableSet view, which contains the Call Map keys in reverse order. Simply put, it gives the key display in reverse order.

4. NavigableMap<K,V> downMap() : Returns the navigable card, which is the opposite of the call card.

5. Map.Entry<K,V> firstEntry() : Returns the first key-value pair associated with the smallest key on the card, or zero if the card is empty.

6. Input.card.Input<K,V> floorInput(K obj) : This method looks for the largest key k such that the key k is less than or equal to the specified key object (k <= obj).

If such a key is found on the card, its entry is returned. Otherwise, a null object is returned.

7. K floorKey(K obj) : This method looks for the largest key k such that the key k is less than or equal to the specified key object (k <= obj).

If such a key is found in the card, it will be returned. Otherwise, a null object is returned.

8. NavigableMap<K,V> headMap(K toKey including boolean) : This method returns a portion of the NavigableMap that contains all CallingCard entries with keys smaller than ToKey. If the included element is true, the element corresponding to the key is included.

9. Input.card<K,V> top input(K obj) : A set is sought for the larger key k than k > obj. If such a key is found in the directory, the key-value pair is returned. Otherwise, a null object is returned.

10. K highKey(K obj) : A set is sought for the larger key k than k > obj. If such a key is found in the card, it will be returned. Otherwise, a null object is returned.

11. Map.Entry<K,V> lastEntry() : This method returns the last entry associated with the largest key on the card, or zero if the card is empty.

12. Map. Input<K,V> Lower input(K obj) : This method looks for a set for the largest key k such that k < obj. If a key is found on the card, its entry is returned. Otherwise, a null object is returned.

13. K lowerKey(K obj) : This method looks for a set for the largest key k such that k < obj. If the key is found in the card, it will be returned. Otherwise, a null object is returned.

14. NavigableSet NavigableKeySet() : Returns the NavigableSet display for the keys in the call card.

I hope this tutorial has covered all the important points regarding the NavigableMap interface in Java and its methods. I hope you understand.
Thanks for reading.

frequently asked questions

What is a navigation map?

The NavigableMap interface is a member of the Java Collection Framework. It is part of the java.util package and is an extension to SortedMap that provides useful navigation methods such as bottomKey, floorKey, ceilingKey and highKey, and thus this popular navigation method.

What is used as a TreeMap in Java?

TreeMap in Java is used to implement the interface Map and NavigableMap, as well as the class AbstractMap. The card is sorted according to the natural order of the keys or using the comparator provided when the card was created, depending on the manufacturer used.

What is SortedMap?

SortedMap is an interface within the framework of collection. This interface is an extension of the Map interface and provides a full sequence of elements (elements can be moved in the order of the sorted keys). The class that implements this interface is TreeMap.

sortedmap in javanavigablemap vs sortedmaptreemap in javanavigablemap java 8navigablemap floorentryunique methods of navigablemapnavigablemap java 11navigablemap ceilingentry

You May Also Like

How To Fix Thumbnails Not Showing In Windows 10

The Windows thumbnail function makes it easy to recognize photos and movies…

A Complete Guide On Resolving The Issue of Phone Overheating

The phone can sometimes even get hot, whether it’s during a game…

How To Fix Windows 10 File Explorer Dark Theme Not Working

When it comes to customisation options, Windows 10 offers users a considerable…

Apex Legends Crashing PC Fix 2020

Various problems can occur during gambling. If you’re playing the new royal…