Behavior
|
|
Unique Elements
|
Since HashSet and TreeSet both
implements Set interface. Both are allowed to store only unique elements in
their objects.
|
Not Thread Safe
|
Both implementations are not
synchronized.
If multiple threads access a hash
set/tree set concurrently, and at least one of the threads modifies the set,
it must be synchronized externally.
|
Clone() method copy technique
|
Both HashSet and TreeSet uses
shallow copy technique to create a clone of
their objects.
|
Fail-fast Iterators
|
The iterators returned by this
class's 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 will throw a ConcurrentModificationException.
|
Tuesday 3 November 2015
Similarities Between HashSet and TreeSet
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment