Java SortedMap Interface

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.