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

查看:266
本文介绍了为什么java链表实现使用接口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?

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

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