Hullaballoonatic
09/11/2018, 10:37 PMhashCode()
for a class whenever i override equals()
? I don't even know what the former doesrobin
09/12/2018, 7:38 AMhashcode
and equals
is something you should know about when doing work on the JVM. The JavaDoc for those two methods is a good start. Most important: If a.equals(b)
is true, then a.hashCode()
and b.hashCode()
have to return the same value. If you don't adhere to this contract, then things like HashMap and HashSet won't work properly.