Solved

HashSet and TreeSet

Posted on 2011-09-07
2
292 Views
Last Modified: 2012-05-12
I wouldd like to know about HashSet and TreeSet.

I read TreeSet we can add only similar type of object whereas in HashSet we can add any type of objects. I was not clear on that. When, how, why we use each of them. thanks in advance
0
Comment
Question by:gudii9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 36495713
TreeSet is always  ordered - so the method to compare elements with each other should be defined for the elements, no if they are completely different it is hardly possible
HashSet is not ordered - so all different objects can be elements of the same HashSet
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36495879
0

Featured Post

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question