Hash
1)Both HashSet and TreeSet implements java.util.Set interface which means they follow contract of Set interface and doesn't allow any duplicates. 2)Both HashSet and TreeSet are not thread-safe and not synchronized. Though you can make them synchronized by using Collections.synchronizedSet() method.
HashSet: not sorted, fast, use equals() method to compare objects and detect duplicates, allows null object. TreeSet: sorted, slow, use compareTo() method, not allow null object.