reference:

how does the hashCode() work

hashCode()

Object generates a HashCode based on the memory address of the instance of the object. Most classes (especially Collection API) should implement their own HashCode (and by contract their own equals method).

equals()

In Java, every object has access to the equals() method because it is inherited from the Object class.

if object1.equals(object2), then hashCode(object1) == hashCode(object2)

You must override hashCode() in every class that overrides equals().

results matching ""

    No results matching ""