The HashSet class implements the Set interface and extends AbstractSet, uses HashTable mechanism to store the elements. It makes no guarantees as to the iteration order of the set, in particular, it does not guarantee that the order will remain constant over time. This class permits the null element.
HashSet Class supports 4 types of constructors
Creates a new empty set which has HashMap as the backing instance with default initial capacity (16) and load factor (0.75).
HashSet(Collection<? extends E> c)
Creates a Set containing all the elements of the specified collection, in the order they are returned by the collection’s iterator.
Creates a new empty Set which has HashMap as the backing instance with the specified initial capacity and load factor (0.75).
HashSet(int initialCapacity, int capacityIncrement)
Creates a new empty Set which has HashMap as the backing instance with the specified initial capacity and load factor.
Methods of Vector Class
Adds the specified element to this set if it is not already present.
Removes all of the elements from this set.
Returns a shallow copy of this HashSet instance, the elements themselves are not cloned.
Returns true if this set contains the specified element.
Returns true if this set contains no elements.
Returns an iterator over the elements in this set.
Removes the specified element from this set if it is present.
Returns the number of elements in this set.