Collision resolution in Java HashMap

前端 未结 9 1991
半阙折子戏
半阙折子戏 2020-12-12 12:29

Java HashMap uses put method to insert the K/V pair in HashMap. Lets say I have used put method and now HashMap<

9条回答
  •  半阙折子戏
    2020-12-12 13:16

    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.

提交回复
热议问题