Hierarchy of HashSet class:
implements Set<E>, Cloneable, java.io.Serializable
- HashSet is sub class of AbstractSet class.
- Underlying data structure of HashSet is HashTable.
- HashSet implements Serializable and Cloneable interfaces
- HashSet does not allow duplicate elements.
- Insertion order is not preserved. No order(Based on hashcode of objects)
Constructors of HashSet:1.HashSet( )
- Creates an empty HashSet object with default initial capacity 16. Fill ratio or load factor 0.75
- This constructor initializes the hash set by using the elements of the collection obj.
- Creates an empty HashSet object with given capacity.
- This constructor initializes both the capacity and the fill ratio (also called load capacity) of the hash set from its arguments (fill ratio 0.1 to 1.0)