class HashSet<E> implements
interface Set<E>
HashSet contains a non-repeating collection of items.
HashSet contains unsorted items.
HashSet allows you to quickly determine whether such an element exists or not (fast because it uses an index that is calculated from the hash code of the element).
HashSet has methods
Add,
Remove,
Contains, but because it uses a hash implementation, these operations take
1 action (the
Contains and
Remove methods in
ArrayList take
n actions.)
HashSet is not synchronized. If multiple threads access a hash set concurrently, and at least one of the threads modifies the
HashSet, it must be synchronized externally. This is typically accomplished by synchronizing using the
Collections.synchronizedSet method:
Java
Set mySet1 = Collections.synchronizedSet( new HashSet(...) );