Collections Question from Dan's Exam:
-----------------------------
a. Each element must be unique.
b. Duplicate elements must not replace old
elements.
c. Elements are not key/value pairs.
Which of these classes provides the specified features?
a. LinkedList
b. TreeMap
c. TreeSet
d. HashMap
e. HashSet
f. Hashtable
g. All of the above
h. None of the above
--------------------------------------------
The answer is e. HashSet
I don't understand why c.TreeSet is not also correct! Any idea?
The answer explains that TreeSet sorts the elements according to the Key! I also dont understand how that is so? I thought keys were used in List implementations not Set. I also don't know why the sorting issue is relevant to the question?!?!