I was going through the add method of HashSet. It is mentioned that
add
HashSet
If this set already contains the element, the call leaves t
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.
HashSet.add
HashMap.put
HashMap