Java HashMap uses put method to insert the K/V pair in HashMap.
Lets say I have used put method and now HashMap<
There is difference between collision and duplication. Collision means hashcode and bucket is same, but in duplicate, it will be same hashcode,same bucket, but here equals method come in picture.
Collision detected and you can add element on existing key. but in case of duplication it will replace new value.