Every object inherits default implementations of hashCode() and equals() from java.lang.Object
. That's why every object can be used in a hash-based collection.
The implementations of those two functions in Object
are obviously very basic but ensure the contract of hashCode()
and equals()
is fulfilled, specifically the a.equals(b) ==> a.hashCode() == b.hashCode()
statement.