HashSet extends the Abstractset and implements the set interface. It creates a collection that is stored using a hash table.
A hash table stores information by using a mechanism called hashing. In hashing, the information content of a key is used to determine a unique value, called its hash code.
The hash code, used as the data in which the key is associated, is stored in the index. The key is converted to its hash code automatically.
The HashSet class supports four constructors. The first form constructs a default hash collection:
HashSet()
The following constructor initializes the hash using the set of elements of C.
HashSet(Collection c)
The following constructor initializes the ability to set the hash to capacity.
The capacity is automatically grown as an element is added to the hash.
HashSet(int capacity)
The
Fourth form initializes the hash two capacity and fill ratio (also known as payload capacity) set from its parameters:
[D, E, F, A, B, C]
Java HashSet Class