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.|
Keep learning and stay tuned to get the latest updates on GATE Exam along with GATE Eligibility Criteria, GATE 2023, GATE Admit Card, GATE Application Form, GATE Syllabus, GATE Cut off, GATE Previous Year Question Paper, and more.
- Difference between Abstract Class and Interface in Java
- Difference between Abstraction and Encapsulation in Java
- Difference between Aggregation and Composition in Java
- Difference between == and .equals() method in Java
- Difference between Primitive and Object Data Types in Java
- Difference between Stack and Heap Memory in Java
- Difference between Throw and Throws in Java