2- public NavigableMap
------------------------------------------------------------------------------------------------------------
1- SortedMap
1-Returns a view of the portion of this map whose keys range from fromKey inclusive, to toKey , exclusive.
2-If fromKey and toKey are equal, the returned map is empty.
3-The returned map is backed by this map, so changes
------------------------------------------------------------------------------------------------------------
2- public NavigableMap
This method is same as upper method but one main difference is that it provide extra facility to inclusive and exclusive key as user demand
---------------------------------------------------------------------------------------------------------------------------------
Example:
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
public class Test {
public static void main(String[] args) {
TreeMap
setmap.put(1, "AAA");
setmap.put(2, "BBB");
setmap.put(3, "CCC");
setmap.put(4, "DDD");
setmap.put(5, "EEE");
SortedMap< Integer, String> simple=setmap.subMap(2, 4);
System.out.println(simple);
SortedMap< Integer, String> simple1=setmap.subMap(2,false, 4,true);
System.out.println(simple1);
}
}
OUTPUT :
{2=BBB, 3=CCC}
{3=CCC, 4=DDD}