Showing posts with label hash. Show all posts
Showing posts with label hash. Show all posts

Wednesday, December 12, 2012

hashCode() and equals()

Rule 1: The connection between hashCode() and equals():
If x.equals(y), then x.hashCode() must be same as y.hashCode().

Rule 2: Overwriting hashCode() or equals():
If you overwrite one of these functions, you have to overwrite the second too.

When you need to overwrite equals?