HashMap uses the hash code of a key to determine where it should be stored in memory. While hash codes help group keys, they are not guaranteed to be unique. If two different keys produce the same hash code (a collision), the HashMap uses the equals() method to distinguish them and identify true duplicates. A key is considered a duplicate only when both the hash code and the equals() comparison match.
sukanya meruva Answered question