Java HashSet class is used to create a collection that uses a hash table for storage. It inherits the AbstractSet class and implements Set interface.
The important points about Java HashSet class are:
public class HashSet
HashSet() It is used to construct a default HashSet.
HashSet(Collection c) It is used to initialize the hash set by using the elements of the collection c.
HashSet(int capacity) It is used to initialize the capacity of the hash set to the given integer value capacity. The capacity grows automatically as elements are added to the HashSet.
It is used to remove all of the elements from this set.
It is used to return true if this set contains the specified element.
It is used to adds the specified element to this set if it is not already present.
It is used to return true if this set contains no elements.
It is used to remove the specified element from this set if it is present.
Near fortis Hostipal