File: EqualsHashCode.md

package info (click to toggle)
error-prone-java 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,076 kB
  • sloc: java: 171,398; xml: 1,459; sh: 34; makefile: 7
file content (7 lines) | stat: -rw-r--r-- 404 bytes parent folder | download
1
2
3
4
5
6
7
The contract for `Object.hashCode` states that if two objects are equal, then
calling the `hashCode()` method on each of the two objects must produce the same
result. Implementing `equals()` but not `hashCode()` causes broken behaviour
when trying to store the object in a collection.

See Effective Java 3rd Edition ยง11 for more information and a discussion of how
to correctly implement `hashCode()`.