Java – NavigableMap Example

Java NavigableMap Example

— A NavigableMap is nothing but a SortedMap extended with navigation methods returning the closest matches for given search targets.
— A NavigableMap may be accessed and traversed in either ascending or descending key order.
— Submaps of any NavigableMap must implement the NavigableMap interface.

Output:

Descending Set : [Z, Y, X, T, B, A]
Floor Entry : B=600
First Entry : A=700
Last Key : Z
First Key : A
Original Map : {A=700, B=600, T=800, X=500, Y=900, Z=200}
Reverse Map : {Z=200, Y=900, X=500, T=800, B=600, A=700}