Merge pull request #10 from kmer1224/patch-2

Update 14. 考虑实现Comparable接口.md
This commit is contained in:
Joe 2019-07-24 17:35:55 +08:00 committed by GitHub
commit 83b8ec9a6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,11 +71,11 @@ public final class CaseInsensitiveString
```java
// Multiple-field `Comparable` with primitive fields
public int compareTo(PhoneNumber pn) {
int result = [Short.compare(areaCode](http://Short.compare(areaCode), pn.areaCode);
if (result == 0) {
result = [Short.compare(prefix](http://Short.compare(prefix), pn.prefix);
int result = Short.compare(areaCode, pn.areaCode);
if (result == 0) {
result = Short.compare(prefix, pn.prefix);
if (result == 0)
result = [Short.compare(lineNum](http://Short.compare(lineNum), pn.lineNum);
result = Short.compare(lineNum, pn.lineNum);
}
return result;
}