首页 > 其他 > 详细

谈一谈Vector类

时间:2019-03-05 00:55:50      阅读:211      评论:0      收藏:0      [点我收藏+]

1.从 Java 2 平台 v1.2 开始,vector类改进为实现 List 接口,成为 Java Collections Framework 的成员。所以vector类有一些遗留的方法。

2.Vector特点:线程安全的,因为很多方法都是同步方法。

3.Oracle官方文档:

  If you need synchronization, a Vector will be slightly faster than an ArrayList synchronized with Collections.synchronizedList. But Vector has loads of legacy operations, so be careful to always manipulate the Vector with the List interface or else you won‘t be able to replace the implementation at a later time. ----摘自 https://docs.oracle.com/javase/tutorial/collections/implementations/list.html

4.即使要线程安全,通常也不用Vector,因为:

  Vector synchronizes on each individual operation. That‘s almost never what you want to do. Generally you want to synchronize a whole sequence of operations. you can decorate a collection using the calls such as Collections.synchronizedList.  ---- 摘自 https://stackoverflow.com/questions/1386275/why-is-java-vector-and-stack-class-considered-obsolete-or-deprecated

 

参考资料:

  1)https://docs.oracle.com/javase/tutorial/collections/implementations/list.html

  2)https://www.jianshu.com/p/a20052ac48f1

  3)https://stackoverflow.com/questions/1386275/why-is-java-vector-and-stack-class-considered-obsolete-or-deprecated

  4)https://blog.csdn.net/shecanwin/article/details/70846690

谈一谈Vector类

原文:https://www.cnblogs.com/xy-ouyang/p/10474169.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!