Because underlying data structure for hashset is hashtable. So in usual case time complexity for basic operations like add, remove, contains and size hashset takes big O of one time, that is, O(1) time.

The final HashSet constructor is as follows. This HashSet constructor accepts Collection (Collection can be ArrayList or LinkedList or Set).

public HashSet(Collection<? extends E> c)

Suppose say in Collection there are three objects and if we pass Collection to above HashSet constructor what happens is above HashSet constructor will create a new HashSet and it will contain whatever elements present in the Collection.

Example on hashset constructor

To explain java hashset constructor example I have created a java program,