ArrayList和Vector和LinkedList的区别
来源:互联网 发布:淘宝服装产品描述 编辑:程序博客网 时间:2024/05/19 00:54
ArrayList和Vector都实现了List接口(List接口继承了Collection接口),他们都是有序集合,即存储在这两个集合中的元素的位置都是有顺序的,相当于一种动态的数组,我们以后可以按位置索引号取出某个元素,,并且其中的数据是允许重复的,这是HashSet之类的集合的最大不同处,HashSet之类的集合不可以按索引号去检索其中的元素,也不允许有重复的元素。
Vector是线程安全的,也就是说是它的方法之间是线程同步的,而ArrayList是线程序不安全的,它的方法之间是线程不同步的。如果只有一个线程会访问到集合,那最好是使用ArrayList,因为它不考虑线程安全,效率会高些;如果有多个线程会访问到集合,那最好是使用Vector,因为不需要我们自己再去考虑和编写线程安全的代码。
ArrayList和LinkedList都是集合实现Collection接口:实现原理不一样:
ArrayList是List接口的大小可变数组的实现,保存在一块连续的空间。LinkedList是List接口的链接列表实现,保存在不连续的空间。
用途不一样:
一般情况都用ArrayList,ArrayList占据内存小,查找速度快。如果经常进行插入、删除操作可以考虑使用LinkedList
阅读全文
0 0
- ArrayList和Vector和LinkedList的区别
- ArrayList,LinkedList,Vector的关系和区别
- ArrayList Vector LinkedList 的区别和用法
- Vector、ArrayList和LinkedList的区别
- ArrayList,LinkedList,Vector的关系和区别
- ArrayList、LinkedList和Vector 的区别
- arrayList 和 LinkedList ,Vector 的区别
- ArrayList、LinkedList和Vector的区别
- ArrayList,Vector和LinkedList的区别
- Vector,ArrayList,LinkedList的特点和区别
- LinkedList、ArrayList和Vector的区别
- LinkedList、ArrayList、 Vector的区别和详解
- ArrayList和LinkedList、Vector的区别?
- ArrayList、Vector和LinkedList的区别
- vector和arrayList,LinkedList区别
- vector和arrayList,LinkedList区别
- Vector, ArrayList和LinkedList区别
- ArrayList、Vector和LinkedList区别
- LDA与PCA都是常用的降维方法,二者的区别
- 浅谈Deep Link
- 文章标题
- JSON和JSONP区别(跨域)
- NOIP集训Week 6总结
- ArrayList和Vector和LinkedList的区别
- 编程作业50页6题 编写程序 输出满足1+2+3...+n<8888的最大正整数n
- 几种常见的优先级顺序
- win7启动 ActiveMQ java.net.URISyntaxException: Illegal character in hostname
- leetcode 454. 4Sum II
- Mybatis学习笔记-MyBatis缓存的使用
- 01 Java并发编程-线程相关概念
- i/o流
- 人工智能第二次作业