为什么javalinkedlist实现使用接口deque? [英] Why does java linkedlist implementation use the interface deque?

查看:24
本文介绍了为什么javalinkedlist实现使用接口deque?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在看 LinkedList 的 java 实现,发现了这个:

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

LinkedList 为什么要支持 Deque 接口?我理解将元素添加到链表末尾的愿望,但这些方法应该已经包含在 List 接口中.

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.

推荐答案

LinkedList 的实现正好满足 Deque 契约,所以为什么不让它实现接口?

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

这篇关于为什么javalinkedlist实现使用接口deque?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆