SortedMap interface extension Map. It ensures that items remain in ascending key order
There are several ways that no item throws a nosuchelementexception exception when calling a map. Throws an ClassCastException exception when an object is incompatible with an element on the map. An nullyiibaierexception exception is thrown when an empty object is attempted or when null values are not allowed on the map.
The following table is summarized using the SortedMap declaration method:
| SN |
Method and Description |
| 1 |
Comparator Comparator ()
Returns a comparer of ordered mappings called. Returns null if the natural order is used to call the map. |
| 2 |
Object Firstkey ()
Returns the first key of a call map. |
| 3 |
SortedMap Headmap (Object end)
Returns an ordered map for those mapping entries with less than the end key. |
| 4 |
Object Lastkey ()
Returns the last key in the invoking map. |
| 5 |
SortedMap SubMap (object start, Object end)
Returns the entries that contain mappings with those that are greater than or equal to the start and less than end keys |
| 6 |
SortedMap Tailmap (Object start)
Returns a mapping containing those entries that are greater than or equal to the start key. |
Example:
SortedMap has its different classes implemented, such as TreeMap, the following is an example to explain the SortedMap functionlaity:
Ayan:1378.0daisy 99.22mahnaz:123.22qadir: -19.08zara:3434.34zara.s current balance:4434.34
Java SortedMap Interface