Search code examples
javacollectionslinked-listsingly-linked-listdoubly-linked-list

What LinkedLists in Collection interface are single or doubly?


I very well understand the concept of SLL or DLL. But which one of them are we using in Collection interface?

So far I have encountered LinkedList in interfaces List,Queue and Dequeue.

Is there any other? And what type of LinkedList are we using in these 3 interfaces? How can I even know it?


Solution

  • List, Queue and Dequeue are just interfaces which provide a contract to be satisfied by the implementation. It doesn't matter how the list is implemented (in fact it doesn't even have to be a list).

    The first line of LinkedList javadoc states

    Doubly-linked list implementation of the List and Deque interfaces.