mirror of
https://github.com/sjsdfg/effective-java-3rd-chinese.git
synced 2025-03-19 22:00:52 +08:00
update
This commit is contained in:
parent
aafa9370c3
commit
fc60374d61
@ -1,4 +1,4 @@
|
||||
# 14.考虑实现 Comparable 接口
|
||||
# 14. 考虑实现 Comparable 接口
|
||||
|
||||
与本章讨论的其他方法不同,`compareTo` 方法并没有在 `Object` 类中声明。 相反,它是 ``Comparable`` 接口中的唯一方法。 它与 Object 类的 equals 方法在性质上是相似的,除了它允许在简单的相等比较之外的顺序比较,它是泛型的。 通过实现 `Comparable` 接口,一个类表明它的实例有一个自然顺序( natural ordering)。 对实现 `Comparable` 接口的对象数组排序非常简单,如下所示:
|
||||
|
Loading…
Reference in New Issue
Block a user