|
SCJP : NavigableMap
public interface NavigableMap
extends SortedMap
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.
This interface additionally defines methods firstEntry, pollFirstEntry, lastEntry, and pollLastEntry that return and/or remove the least and greatest mappings, if any exist, else returning null.
NavigableMap use key value pairs to put the value.
import java.util.NavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;
public class Test {
public static void main(String... args) {
NavigableMap navMap = new ConcurrentSkipListMap();
navMap.put(4, "April");
navMap.put(5, "May");
navMap.put(6, "June");
navMap.put(1, "January");
navMap.put(2, "February");
navMap.put(3, "March");
System.out.print(navMap.firstEntry());
System.out.print(navMap.lastEntry());
System.out.print(navMap.get(6));
}
}
The output:
1=January
6=June
June
| |