java vector中_在java中vector代表什么意思?大大帮忙,一定给分

不是java没有指针么?

|

表示矢量

可以用来代替数组

主要不同是vector的长度可以自动增长

而数组不行

|

类似于集合。可作为动态数组使用。可以存储任何内容,同一个Vector可以存储Integer,String,以及任何类(包括Vector)。可以实现复杂的数据结构

为了存储一个简单类型,需要转为一个对象,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

|

一数据结构,类似与数组,但其长度可变

|

普通数组长度不可变,而vector长度可变,但它只能存储对象

|

可以说java的应用是安全指针!

|

象hashmap

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值