Java集合-LinkedList

Java集合-LinkedList

特性

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

1、继承于 AbstractSequentialList ,本质上面与继承 AbstractList 没有什么区别,AbstractSequentialList 完善了 AbstractList 中没有实现的方法。

2、Serializable:成员变量 Node 使用 transient 修饰,通过重写read/writeObject 方法实现序列化。

3、Cloneable:重写clone()方法,通过创建新的LinkedList 对象,遍历拷贝数据进行对象拷贝。
4、Deque:实现了Collection 大家庭中的队列接口,说明他拥有作为双端队列的功能。

LinkedList与ArrayList最大的区别就是LinkedList中实现了Collection中的 Queue(Deque)接口 拥有作为双端队列的功能

基本属性

链表没有长度限制,他的内存地址不需要分配固定长度进行存储,只需要记录下一个节点的存储地址即可完成整个链表的连续。

java 复制代码
//当前有多少个结点,元素个数
transient int size = 0;
//第一个结点
transient Node<E> first;
//最后一个结点
transient Node<E> last;
//Node的数据结构
private static class Node<E> {
    E item;//存储元素
    Node<E> next;//后继
    Node<E> prev;//前驱
    Node(Node<E> prev, E element, Node<E> next) {
        this.item = element;
        this.next = next;
        this.prev = prev;
    }
}
相关推荐
014-code6 小时前
订单超时取消与库存回滚的完整实现(延迟任务 + 状态机)
java·开发语言
lly2024066 小时前
组合模式(Composite Pattern)
开发语言
游乐码7 小时前
c#泛型约束
开发语言·c#
Dontla7 小时前
go语言Windows安装教程(安装go安装Golang安装)(GOPATH、Go Modules)
开发语言·windows·golang
chushiyunen7 小时前
python rest请求、requests
开发语言·python
铁东博客7 小时前
Go实现周易大衍筮法三变取爻
开发语言·后端·golang
baidu_huihui7 小时前
在 CentOS 9 上安装 pip(Python 的包管理工具)
开发语言·python·pip
南 阳7 小时前
Python从入门到精通day63
开发语言·python
lbb 小魔仙7 小时前
Python_RAG知识库问答系统实战指南
开发语言·python
java1234_小锋7 小时前
Java高频面试题:Springboot的自动配置原理?
java·spring boot·面试