What happens when we add duplicate elements in LinkedHashSet?

  1. They are stored in order
  2. They are added at the end
  3. Only first occurrence is stored
  4. An exception is thrown
Correct answer Only first occurrence is stored

Explanation

LinkedHashSet ignores duplicates and keeps only the first occurrence.

Update: Admin added a tag on this question

Topics

By Admin · · 24 views