mirror of
https://github.com/sjsdfg/effective-java-3rd-chinese.git
synced 2025-01-06 10:20:58 +08:00
Merge pull request #10 from kmer1224/patch-2
Update 14. 考虑实现Comparable接口.md
This commit is contained in:
commit
83b8ec9a6e
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user