Why must equals and hashCode agree for keys stored in HashMap?
HashMap uses a key’s hash code to locate a bucket and equality to identify the matching key. If two equal objects produce different hash codes, lookup may search the wrong bucket. Equal objects must t...