0

Explanation is Needed. Please help me

we need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability?

14th Dec 2017, 3:50 AM
Saif
Saif - avatar
2 ответов
+ 1
YOU NEED TO USE LinkedHashSet The HashSet class does not automatically retain the order of the elements as they're added. To order the elements, use a LinkedHashSet, which maintains a linked list of the set's elements in the order in which they were inserted.
14th Dec 2017, 5:27 AM
shashank singh
shashank singh - avatar
0
Set store only unique elements, I am not sure about natural order.
14th Dec 2017, 4:05 AM
Dima Makieiev
Dima Makieiev - avatar