HashSet and TreeSet

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
LVL 7
gudii9Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
for_yanConnect With a Mentor Commented:
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
 
for_yanCommented:
0
All Courses

From novice to tech pro — start learning today.