The natural order that Java often mentions (Natural ordering)

Source: Internet
Author: User
Tags comparable

Natural ordering are often referred to in containers and appear with iterators.

A description was found in the API specification of the comparable interface.

(https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html)

The natural ordering for a class C was said to being consistent with equals if and only if E1.compareto (e2) = = 0 has the same Boolean value as E1.equals (E2) for every E1 and E2 of Class C.

Note that NULL was not an instance of any class, and e.compareto (null) should throw a nullpointerexception even though E.eq Uals (NULL) returns FALSE.

That is, for any instance object E1 and E2 of Class C, the expression "E1.compareto (e2) = = 0" Returns the same Boolean value as the other expression "e1.equals (E2)".

The natural order that Java often mentions (Natural ordering)

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.