3 ms·
Yes, seems it was just for hash tables. From the JDK 1.0 doc: """ Returns a hash code value for the object. This method is supported for the benefit of hasht
by cmckn 5y ago
Yes, seems it was just for hash tables. From the JDK 1.0 doc:
"""
Returns a hash code value for the object. This method is
supported for the benefit of hashtables such as those provided by
<code>java.util.Hashtable</code>.
The general contract of <code>hashCode</code> is:
Whenever it is invoked on the same object more than once during
an execution of a Java application, the <code>hashCode</code> method
must consistently return the same integer. This integer need not
remain consistent from one execution of an application to another
execution of the same application.
If two objects are equal according to the <code>equals</code>
method, then calling the <code>hashCode</code> method on each of the
two objects must produce the same integer result.
"""
hashCode is also related to object comparison (see the last line) and this was 2 Java releases before `Comparable` existed.