Comparison of programming languages (associative array): Difference between revisions

Content deleted Content added
m dab
god
Line 429:
 
For two objects ''a'' and ''b'',
* <source lang="java">
a.equals(b) == b.equals(a)</source>
* <source lang="java">if a.equals(b), then a.hashCode() == b.hashCode()
</source>
 
In order to maintain this contract, a class that overrides <code>equals()</code> must also override <code>hashCode()</code>, and maybe vice versa, so that <code>hashCode()</code> is based on the same properties (or a subset of the properties) as <code>equals()</code>.