What is the primary difference between a `List` and a `Set` in Java?
A `List` stores elements in a random order and allows duplicates, while a `Set` stores elements in sorted order without duplicates.
Iâ€™m a bit disappointed with this answer. The `List` maintains the insertion order, not random, and the `Set` doesn't guarantee sorted order unless using a specific implementation like `TreeSet`.
Can you explain how `TreeSet` differs from `HashSet` in terms of ordering?