JAVA新手在使用JAVA的时候大概都会遇到这个问题:

JAVA中的Array, ArrayList, Vector, List, LinkedList有什么样的区别?尤其是Vector, ArrayList, Array之间的区别?因为这三个概念从本质上来说都是一样的,都是数组的数据结构

关于这个问题,这里有篇文章:

http://www.javaworld.com/javaworld/javaqa/2001-06/03-qa-0622-vector.html

已经解释得很清楚了,我简单概括一下。

Vector这个类是thread safe的。就是说,多线程同时调用同一个Vector的方法不会造成数据的混乱。而ArrayList不是thread safe。所以,如果是多线程的程序,多使用Vector,这样不需要自己维护concurrency。

数据的增长模式不一样。无论是Vector还是ArrayList,内部都是用一个Array来实现的,这就意味着,一旦数据越来越多超过了原来Array的容量的时候,Vector和ArrayList都需要扩充Array来满足新的数据。Vector每次扩充的时候都增长一倍,就是说新的Array的size是旧的Array的size的2倍。而ArrayList每次扩充,它的Array的size只增加50%.

最后,如果程序对于性能要求很高的话,Vector和ArrayList最好哪个都别用,而使用原始的Array。

Vector, ArrayList, Array的更多相关文章

  1. Namespace, string, vector and array

    1. Headers should not include using declaration Code inside headers ordinarily should not include us ...

  2. Vector/Arraylist与Linklist的区别

        SDK提供了有序集合接口java.util.List的几种实现,其中三种最为人们熟知的是Vector.ArrayList和    LinkedList.有关这些List类的性能差别是一个经常被 ...

  3. Hashtable,HashMap,TreeMap有什么区别?Vector,ArrayList,LinkedList有什么区别?int和Integer有什么区别?

    接着上篇继续更新. /*请尊重作者劳动成果,转载请标明原文链接:*/ /*https://www.cnblogs.com/jpcflyer/p/10759447.html* / 题目一:Hashtab ...

  4. 09 Collection,Iterator,List,listIterator,Vector,ArrayList,LinkedList,泛型,增强for,可变参数,HashSet,LinkedHashSet,TreeSet

    09 Collection,Iterator,List,listIterator,Vector,ArrayList,LinkedList,泛型,增强for,可变参数,HashSet,LinkedHas ...

  5. Vector & ArrayList Hashtable & HashMap ArrayList & LinkedList

    1. Vector & ArrayList 1)  Vector的方法都是同步的(Synchronized),是线程安全的(thread-safe),而ArrayList的方法不是,由于线程的 ...

  6. java面试题(杨晓峰)---第八讲谈谈Vector,ArrayList,LinkedList有何区别?

    Vector,ArrayList,LinkedList均为线性的数据结构,但是从现实方式与应用场景中又存在差别. 1 底层实现方式 ArrayList内部数组来实现,LinkedList内部采用双向链 ...

  7. C++标准库分析总结(四)——<Vector、Array、Forward_list设计原则>

    本节主要总结标准库Vector和Array的设计方法和特性以及相关迭代器内部特征 1.Vector 1.1 Vector 内部实现 Vector是自增长的数组,其实在标准库中没有任何一种容器能原地扩充 ...

  8. vector以及array和数组

    //比较数组.vector.array #include <iostream> #include <vector> #include <array> #includ ...

  9. 迭代器遍历列表 构造方法 constructor ArrayList Vector LinkedList Array List 时间复杂度

    package priceton; import java.io.IOException; import java.util.concurrent.CyclicBarrier; import java ...

随机推荐

  1. python运维开发(二十三)---tornado框架

    内容目录: 路由系统 模板引擎 cookie 加密cookie 自定义api 自定义session 自定义form表单验证 异步非阻塞 web聊天室实例 路由系统 路由系统其实就是 url 和 类 的 ...

  2. Python模块的介绍

    Python模块的学习: 1.os模块: 下面只对os模块中几个比较常用的方法做一些简单的示例: os.system():这个方法在shell中体现的比较多,在dos命令行中也可以执行,下面就以在do ...

  3. Cows(poj 2481 树状数组)

    Cows Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 15301   Accepted: 5095 Description ...

  4. MVC 过滤

    我们来看两个接口: public interface IActionFilter { // Methods void OnActionExecuted(ActionExecutedContext fi ...

  5. JSONP跨域的原理

    一种脚本注入行为 在 2011年10月27日 那天写的     已经有 12671 次阅读了 感谢 参考或原文   服务器君一共花费了23.005 ms进行了2次数据库查询,努力地为您提供了这个页面. ...

  6. Json之语法,格式

    JSON 文本格式在语法上与创建 JavaScript 对象的代码相同.由于这种相似性,无需解析器,JavaScript 程序能够使用内建的 eval() 函数,用 JSON 数据来生成原生的 Jav ...

  7. Oracle 10g体系机构及安全管理《思维导图》

    通过学习Oracle数据库后,我对数据库又有了进一步的了解,Oracle数据库 10g体系机构分为 物理和逻辑存储结构. 下面是我对Oracle数据库做的思维导图和笔记 (全屏查看:<思维导图& ...

  8. 35+雪花Logos设计灵感

    快中秋节放假了,给大家分享一些雪花Logos设计灵感,陶冶下心情吧! 原文地址:http://www.goodfav.com/35-snowflake-logos-ideas-17134.html V ...

  9. mysql 事务控制

    #!/usr/bin/perl use DBI; $db_name='zjzc'; $ip='127.0.0.1'; $user="root"; $passwd="123 ...

  10. View not attached to window manager crash 的解决办法

    View not attached to window manager crash 的解决办法 转自:http://stackoverflow.com/questions/22924825/view- ...