What is the difference between hashset and treeset in java?
Answer / Abhinaya Bhullar
{"hashset": "An implementation of the Set interface that allows null elements. HashSet does not guarantee the order of its elements, nor does it maintain any order.","treeset": "A sorted set that stores its elements in a red-black tree, which is self-balancing binary search tree that provides guaranteed log(n) time complexity for basic operations like add, remove, and contains.","difference": "HashSet does not guarantee the order of its elements, while TreeSet maintains a sorted order of its elements. HashSet allows null elements whereas TreeSet does not allow duplicate null elements."}
| Is This Answer Correct ? | 0 Yes | 0 No |
waht You know about thread programming?
What is constructor and virtual function? Can we call a virtual function in a constructor?
What is the default execution method in java?
Enlist few advantages of inheritance?
Is main a function?
In Java list the methods that can be overridden?
What is difference between Iterator and for loop
What do you understand by the bean persistent property?
what is method reference in java 8?
What is difference between final and finally in java?
What are the common uses of "this" keyword in java ?
What is the use of join method?