当前位置: 技术问答>java相关
在java中vector代表什么意思?大大帮忙,一定给分
来源: 互联网 发布时间:2015-03-20
本文导语: 不是java没有指针么? | 表示矢量 可以用来代替数组 主要不同是vector的长度可以自动增长 而数组不行 | 类似于集合。可作为动态数组使用。可以存储任何内容,同一个Vector...
不是java没有指针么?
|
表示矢量
可以用来代替数组
主要不同是vector的长度可以自动增长
而数组不行
可以用来代替数组
主要不同是vector的长度可以自动增长
而数组不行
|
类似于集合。可作为动态数组使用。可以存储任何内容,同一个Vector可以存储Integer,String,以及任何类(包括Vector)。可以实现复杂的数据结构
为了存储一个简单类型,需要转为一个对象,eg:int->Integer
为了存储一个简单类型,需要转为一个对象,eg:int->Integer
|
vector 向量,存放对象的可变数组
|
java.util
Class Vector
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--java.util.Vector
All Implemented Interfaces:
Cloneable, Collection, List, RandomAccess, Serializable
Direct Known Subclasses:
Stack
--------------------------------------------------------------------------------
public class Vector
extends AbstractList
implements List, RandomAccess, 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.
Since:
JDK1.0
See Also:
Collection, List, ArrayList, LinkedList, Serialized Form
Class Vector
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--java.util.Vector
All Implemented Interfaces:
Cloneable, Collection, List, RandomAccess, Serializable
Direct Known Subclasses:
Stack
--------------------------------------------------------------------------------
public class Vector
extends AbstractList
implements List, RandomAccess, 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.
Since:
JDK1.0
See Also:
Collection, List, ArrayList, LinkedList, Serialized Form
|
一数据结构,类似与数组,但其长度可变
|
普通数组长度不可变,而vector长度可变,但它只能存储对象
|
可以说java的应用是安全指针!
|
象hashmap