ArrayList、LinkedList和Vector的区别
本文最后更新于:2021年10月7日 晚上
ArrayList、LinkedList 和 Vector 的区别
一、区别
相同点
这三个类都实现了 Collection 接口,存储数据的特点相同:存储有序的、可重复的数据
不同点
- ArrayList 作为 List 接口的主要实现类,线程不安全,效率高,底层使用 Object[] elementData 存储
- LinkedList 对于频繁的插入、删除操作,使用此类效率比 ArrayList 高,底层使用双向链表存储
- Vector 作为 List 接口古老实现类,线程安全,效率低,底层使用 Object[] elementData 存储
二、源码分析
- ArrayList
1 | |
- LinkedList
1 | |
- Vector
1 | |
ArrayList、LinkedList和Vector的区别
http://qingyux.cn/2023/04/04/ArrayList、LinkedList和Vector的区别/