Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does java linkedlist implementation use the interface deque?

I was looking at the java implementation of LinkedList, and found this:

public class LinkedList<E> 
       extends AbstractSequentialList<E> implements List<E>,
               Deque<E>, Cloneable, java.io.Serializable

Why should a LinkedList support the Deque interface? I understand the desire to add elements to the end of the linked list, but those methods should have been incuded in the List interface.

like image 282
Abhijeet Kashnia Avatar asked Dec 12 '22 13:12

Abhijeet Kashnia


1 Answers

The LinkedList implementation happens to to satisfy the Deque contract, so why not make it implement the interface?

like image 56
Qwerky Avatar answered Apr 07 '23 02:04

Qwerky