Skip to content

Commit

Permalink
fix ch10
Browse files Browse the repository at this point in the history
  • Loading branch information
wizardforcel committed Sep 20, 2017
1 parent 0849ccf commit 03c7312
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 10.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public class SillyString {
}
```

注意`SillyString`重写了`equals`和`hashCode`。这个很重要。为了正常工作,`equals`必须和`hashCode`,这意味着如果两个对象被认为是相等的 - 也就是说,`equals`返回`true` - 它们应该有相同的哈希码。但这个要求只是单向的;如果两个对象具有相同的哈希码,则它们不一定必须相等。
注意`SillyString`重写了`equals`和`hashCode`。这个很重要。为了正常工作,`equals`必须和`hashCode`一致,这意味着如果两个对象被认为是相等的 - 也就是说,`equals`返回`true` - 它们应该有相同的哈希码。但这个要求只是单向的;如果两个对象具有相同的哈希码,则它们不一定必须相等。

`equals`通过调用`toString`来工作,返回`innerString`。因此,如果两个`SillyString`对象的`innerString`实例变量相等,它们就相等。

Expand Down

0 comments on commit 03c7312

Please sign in to comment.