Hi.
What is the difference between TreeSet and HashSet?
Difference between TreeSet and HashSet
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Oct 31, 2011, 9:01 AM EDT
http://download.oracle.com/javase/6/docs/api/java/util/HashSet.html
http://download.oracle.com/javase/6/docs/api/java/util/TreeSet.html
AartiRank #2,383 · 594 reputationPosted Nov 16, 2011, 7:54 PM EST
A treeSet organizes data in a tree through use of Comparator (natural ordering) and the hashSet organizes data in a hash table (using a hash function).
See the Java API for more info:
http://www.j2ee.me/javase/6/docs/api/java/util/TreeSet.html
http://java.sun.com/javase/6/docs/api/java/util/HashSet.html
The previous answer (unless I'm mistaken) is pretty much completely wrong...
Regards
Prabhu RajaRank #861 · 2.6K reputationPosted Nov 16, 2011, 9:04 PM EST
http://vidyapsi.wordpress.com/2009/01/22/treeset-vs-hashset-vs-linkedhashset/