HashSet
implements Set
-
Underlying Data Structure: Hashtable
-
Insertion Order - NOT Preserved (in order of hashcode)
-
Best choice for: Search Operations
-
Worst choice for:
-
Constructors:
HashSet h = new HashSet();
HashSet h = new HashSet(int initialCapacity)
HashSet h = new HashSet(int initialCapacity, float loadFactor)
HashSet h = new HashSet(Collection C)
-
Default initial capacity: 16
-
Load factor/fill ratio: 0.75
-
New Capacity:
-
What will happen if we try to enter duplicate value for set? add() method will return false. šš½ return type is boolean
-
Insertion order Object stored in order of hashcode() šš½ Makes it best choice for search operations
Child classes/interfaces:
Children
Backlinks