Explain the both HashSet and TreeSet?
HashSet is an unordered, unsorted Set.
It's a Collection set which restrict duplicate elements and also repositioning of elements.
It implements Set interface and extends AbstractSet.
Uses hash code of object being inserted.
TreeSet is a Set implemented when we want elements in a sorted order.
Sorting of element is done according to natural order of elements or by help of comparator provided at creation time.