public class Vector
extends AbstractList
implements List, Cloneable, Serializable
The Vector class implements a growable array of objects. Like an array, it contains components that can be accessed using an integer index. However, the size of a Vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created.Each vector tries to optimize storage management by maintaining a capacity and a capacityIncrement. The capacity is always at least as large as the vector size; it is usually larger because as components are added to the vector, the vector's storage increases in chunks the size of capacityIncrement. An application can increase the capacity of a vector before inserting a large number of components; this reduces the amount of incremental reallocation. As of the Java 2 platform v1.2, this class has been retrofitted to implement List, so that it becomes a part of Java's collection framework. Unlike the new collection implementations, Vector is synchronized.The Iterators returned by Vector's iterator and listIterator methods are fail-fast: if the Vector is structurally modified at any time after the Iterator is created, in any way except through the Iterator's own remove or add methods, the Iterator will throw a ConcurrentModificationException. Thus, in the face of concurrent modification, the Iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future. The Enumerations returned by Vector's elements method are not fail-fast.
extends AbstractList
implements List, Cloneable, Serializable
The Vector class implements a growable array of objects. Like an array, it contains components that can be accessed using an integer index. However, the size of a Vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created.Each vector tries to optimize storage management by maintaining a capacity and a capacityIncrement. The capacity is always at least as large as the vector size; it is usually larger because as components are added to the vector, the vector's storage increases in chunks the size of capacityIncrement. An application can increase the capacity of a vector before inserting a large number of components; this reduces the amount of incremental reallocation. As of the Java 2 platform v1.2, this class has been retrofitted to implement List, so that it becomes a part of Java's collection framework. Unlike the new collection implementations, Vector is synchronized.The Iterators returned by Vector's iterator and listIterator methods are fail-fast: if the Vector is structurally modified at any time after the Iterator is created, in any way except through the Iterator's own remove or add methods, the Iterator will throw a ConcurrentModificationException. Thus, in the face of concurrent modification, the Iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future. The Enumerations returned by Vector's elements method are not fail-fast.
解决方案 »
- 关于struts2整Spring3
- Jsp和tomcat 的问题?
- 在线等待,tomcat问题,解决就给分!!!!!!!!
- JAVAMAIL的问题高手快了!!!!!!!!!!!!!!!
- 在win2000下如何用jdk编译和运行java程序?
- 启动tomcat出现问题
- 为什么我编译最基本的java文件总出错,告诉我import javax.servlet.http.*包
- 请所有人进来看看,能解决的送500分!
- 初学jsp的asp程序员的十个疑问
- eclipse database source explorer 配置sqlserver的问题
- 我用一个图片的onclick时间调用一个函数如下,能调用,但
- 各位高手帮帮忙,我快要疯了,救救我吧!(Applet 与 Servlet 通讯)
有点类似于数组。
一般这样实例化一个向量。java.util.Vector vObj = new java.util.Vector() ;
一般用:vObj.addElement("abc")来对向量增加值。
用vObj.elementAt(i)来取值。i为vObj中数据的索引。
如:
String sStr = "" ;
for(int i=0;i<vObj.size();i++)
sStr = (String)vObj.elementAt(i);用向量的好处:对向量增加值时不必要预先知道向量的长度有多大。
比数组要灵活。更详细的说明你可去查参考资料。
讲了一些Collections的性能评测(包括:Vector,ArrayList,LinkedList),或许看完后就知道Vector是什么,和其他的集合的比较有什么优点和缺点了.可以用于那一方面的应用了.
讲了一些Collections的性能评测(包括:Vector,ArrayList,LinkedList),或许看完后就知道Vector是什么,和其他的集合的比较有什么优点和缺点了.可以用于那一方面的应用了.