Update 14. 考虑实现Comparable接口.md

wrong  snippets in `compareTo` method for the `PhoneNumber` class
This commit is contained in:
Allen Chang 2019-07-24 14:53:50 +08:00 committed by GitHub
parent 28e51ff3ca
commit 9e9d80eb73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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