Which of the following data structures does not allow duplicate elements?

  • ArrayList
  • HashSet
  • LinkedList
  • TreeMap
The HashSet data structure in Java does not allow duplicate elements. It is implemented using a hash table and ensures that all elements are unique by using the hashing mechanism. ArrayList and LinkedList can contain duplicate elements, while TreeMap allows duplicates based on keys.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *