How does HashSet not allow duplicates?

后端 未结 6 2075
情歌与酒
情歌与酒 2021-02-06 23:17

I was going through the add method of HashSet. It is mentioned that

If this set already contains the element, the call leaves t

6条回答
  •  广开言路
    2021-02-06 23:37

    As you can see the HashSet.add method adds the element to the HashMap.put as a key not as a value. Value is replaced in the HashMap not the key.

提交回复
热议问题