All About SortedMap Interface in Collection in Java



All About SortedMap Interface in Collection in Java


The SortedMap interface extends the Map interface. The SortedMap interface contains elements in ascending order based on keys. The functionality of SortedMap is analogous to SortedSet. This is implemented in the TreeMap class.

The method available in the SortedMap interface are:


comparator()//returns the comparator of the SortedMap.It returns null if the sorted map uses
//natural ordering for their key
firstKey();//Returns the first key of the SortedMap.
headMap(Object end);//Returns the keys of the SortedMap that are less than the specified end key.
lastKey();//returns the last key of the SortedMap.
subMap(Object start,Object end);// returns the keys of the SortedMap that are greater than or equal
//to the specified start object and less than or equal to the specified end object.
tailMap(Object start);//Returns the keys of the SortedMap that are greater than or equal 
//to the start object.
 
All About SortedMap Interface in Collection in Java All About SortedMap Interface in Collection in Java Reviewed by Animesh Chatterjee on December 20, 2018 Rating: 5

No comments:

Powered by Blogger.