As per the HashSet.java, the internal design of the HashSet uses HashMap
public HashSet() {
map = new HashMap<>();
}
the java doc says
This class implements the
Setinterface, backed by a hash table (actually aHashMapinstance).
Most of the books refer HashSet as "it is implemented by a hash table" by Java Generics
What is the reason for the strech of the HashTable ? Why not HashMap ?
HashTableclass. en.wikipedia.org/wiki/Hash_table