ProAnswers.org

What is difference between HashSet and TreeSet?

HashSet maintains no order whereas TreeSet maintains ascending order.

1)HashSet is under set interface i.e. it does not guarantee for either sorted order or sequence order.

1)TreeSet is under set i.e. it provides elements in a sorted order (acceding order).

2)We can add any type of elements to hash set.

2)We can add only similar types of elements to tree set.