Please consider the below piece of code:
HashSet hs = new HashSet(); hs.add(\"hi\"); -- (1) hs.add(\"hi\"); -- (2)
hs.size() w
hs.size()
In the case of HashMap, it replaces the old value with the new one.
In the case of HashSet, the item isn't inserted.