Difference between treeSet and hashSet..? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Difference between treeSet and hashSet..?

14th Feb 2017, 1:17 PM
Himanshu Melkani
Himanshu Melkani - avatar
2 Answers
+ 3
Both are collections which implement the Set interface and dont allow duplicates. The major difference between them two is that TreeSet is an ordered collection whereas HashSet is unordered which means the order in which you add items isnt guaranteed to be maintained once you want to access them again.
14th Feb 2017, 1:27 PM
Ousmane Diaw
0
so how can i guess the order then
14th Feb 2017, 1:29 PM
Himanshu Melkani
Himanshu Melkani - avatar