Know Also : What is HashSet In Java ? and What is TreeSet In Java ?
HashSet
|
TreeSet
|
HashSet does’nt maintain insertion order of
elements.
|
TreeSet by default maintain natural order of elements.
|
HashSet allows null elements.
|
TreeSet not allows null elements.
|
HashSet is not rich in functionality as comparison
with TreeSet.
|
TreeSet is rich in functionality because it has
some methods like pollFirst(), pollLast(), first(), last(), ceiling(),
lower(), etc.
|
HashSet uses equal() method for camparison.
|
TreeSet uses campareTo() method for camparison.
|
Its speed is slow than HashSet.
|
|
It is backed by HashTable.
|
It is backed by Red Black Tree.
|
HashSet
|
TreeSet
|
It doesn’t allow duplicate elements.
|
It doesn’t allow duplicate elements.
|
It is not synchronized and thread-safe.
|
It is not synchronized and thread-safe.
|
It is fail-fast iterator.
|
It is fail-fast iterator.
|
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.
This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.
This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.



No comments:
Post a Comment