Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

HashSet and TreeSet

Posted on 2011-09-07
2
Medium Priority
?
298 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

647 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