Which collection should you choose to store unique items with no duplicates?
Options
ListSet(Correct option)Mapwith duplicate keysQueue
Answer
Set
Why
The Collections Framework gives you ready-made data structures:
List: ordered, allows duplicates, access by position (ArrayList).Set: no duplicates (HashSet,TreeSet).Map: key to value pairs, unique keys (HashMap).Queue/Deque: items processed in order (ArrayDeque).
Adding an existing item to a Set simply does nothing.
Remember
List = ordered with duplicates. Set = unique. Map = key to value.