Implements the Set interface.
Provides hash table data structure. Elements are stored randomly, and elements are accessed by their hash code. Each element has a unique hash code.
HashSet is not synchronized, after modifying by a thread, need external synchronization.
Constructor signatures:
(): default capacity is 16, default load factor is 0.75
(capacity in int, load factor in float): how many elements it can store, if load factor is exceeded, the set is moved to an other set with double size
(other Set class): converting from that set to HashSet; need identical pair types
EXAMPLE FOR CREATING AN INSTANCE OF HASHSET:
All methods of Set are available. Other methods are below.
Differences between HashSet and TreeSet:
TreeSet stores element order, HashSet does not
TreeSet provides navigation methods along the elements, HashSet does not
HashSet is faster for basic operations like add, remove, contains and size than TreeMap
EXAMPLE FOR CONVERTING ARRAY AND BACK: