首页 > 编程语言 > 详细

Java 常提到的自然序(Natural Ordering)

时间:2018-05-18 01:08:59      阅读:327      评论:0      收藏:0      [点我收藏+]

  Natural Ordering常在容器中被提到,和迭代器一起出现。

  在Comparable接口的API规范中找到了描述。

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

 

  The natural ordering for a class C is said to be 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 is not an instance of any class, and e.compareTo(null) should throw a NullPointerException even though e.equals(null) returns false.

 

  即对于类C的任意实例对象e1和e2,表达式“e1.compareTo(e2) == 0”与另一个表达式“e1.equals(e2) ”返回相同的布尔值。

Java 常提到的自然序(Natural Ordering)

原文:https://www.cnblogs.com/bigbigbigo/p/9054068.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!