Question PRG-JAVA-0057
MediumWhat is the difference between HashSet and TreeSet in Java?
- A.
They are the same
- B.
TreeSet allows duplicates
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Java question
What is the difference between HashSet and TreeSet in Java?
They are the same
TreeSet allows duplicates
Sign up free to see the answer and a step-by-step explanation.
HashSet has O(1) average operations with no order; TreeSet keeps elements sorted with O(log n) operations
HashSet is sorted