Archives: Iterator

Java – NavigableSet Example

Java NavigableSet Example

— A NavigableSet is nothing but a SortedSet extended with navigation methods reporting closest matches for given search targets.
— A NavigableSet may be accessed and traversed in either ascending or descending order.
— Subsets of any NavigableSet must implement the NavigableSet interface.

Output:

Original Set :
Z
X
T
B
A
Sorted Navigable Set :
A
B
T
X
Z
Head Set : [A, B, T].
Tail Set : [X, Z].
Sub Set : [B, T, X].
Last Element : Z
First Element : A
Reverse Set : [Z, X, T, B, A]
Original Set : [A, B, T, X, Z]