What is Hashset and Tresset?
Hashset is the execution of the set interface and is backed by hashmap, while on the other hand, Tree set executes sorted sets and is backed by TreeMap.
Difference between Hashset and Treeset in Java
|1||The Hash set is executed with the help of a HashTable.||The tree set is executed with the help of a tree structure.|
|2||It does not authorise a heterogeneous object.||It authorises a heterogeneous object.|
|3||It permits a null object.||It does not permit the null object.|
|4||To compare two objects, we use the equals method.||To compare two objects, we use the compare method.|
|5||It does not support any order||TreeSet supports an object in sorted order.|