javacollectionslinkedhashset

LinkedHashSet implementations of HashTable and LinkedList?


I came across the below in the JAVA docs related to the LinkedHashSet:

Hash table and linked list implementation of the Set interface, with predictable iteration order.

But If I see the source of LinkedHashSet I am not able to find any implements/extends related to HashTable or LinkedList. Then how does it inhibits the features of both these data structures?


Solution

  • It does not inherit from those classes, or use them in any way.

    But you could write your own linked list class, and it would still be a linked list, even if it had no relationship to java.util.LinkedList. That's how LinkedHashSet works: it does not use java.util.Hashtable, nor java.util.LinkedList, but it has an implementation of the data structures nonetheless.