Thursday 17 April 2014

HashSet

HashSet implements the Set interface, which don't permits duplicate elements. HashSet permits null element. HashSet offers constant time performance for add, remove, contains and size operations.

HashSet is not synchronized, To make use of Synchronized set use the below statement.

Set synchSet = Collections.synchronizedSet(new HashSet());

synchSet acts as a synchronized set.

The iterators returned by this class's iterator method are fail-fast: if the set is modified at any time after the iterator is created, in any way except through the iterator's own remove method, the Iterator throws a ConcurrentModificationException.

HashSet uses HashMap internally for all the operations.


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment