王朝网络
分享
 
 
 

java.util.Vector翻译

王朝java/jsp·作者佚名  2006-01-10
宽屏版  字体: |||超大  

[/url] [url=file:///F:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/overview-summary.html]Overview

Package

Class

Use

Tree

Deprecated

Index

Help

JavaTM 2 Platform

Std. Ed. v1.4.2

PREV CLASS NEXT CLASS

FRAMES NO FRAMES All Classes

SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

java.util

Class Vectorjava.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, SerializableThe 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. Vector类实现了一个可增长对象数组。和数组一样,它所包含的成员可以使用整型 下标访问。然而,Vector可以创建后在添加或删除项有需要时增加或减小大小。

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. 每一个vector都试图通过对capacity和capacityIncrement的维护来优化存储管理。 capacity至少应和vector的大小一样,通常情况下要更大,因为成员被加入vector 时,vector的容量每次会增加capacityIncrement的大小。应用程序可以在插入 大量成员之前增加vector的大小,这将减少增长重分配的次数。

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. 从Java 2平台1.2以来,该类已作更改以实现List,因此它成了Java集合框架的一部分。 和其他新的集合实现不同,Vector是同步化的。

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. 由Vector的的iterator和listIterator方法返回的Iterator也具有fail-fast特性:即如果Vector在Iterator创建后使用除Iterator自身的remove或add方法以外的方式使其有了结构性更改,Iterator将抛出ConcurrentModificationException。因此,遇到同步修改时,Iterator会立即失败,宁可不冒未来某一时刻不能确定的行为风险。 Vector的elements方法返回的Enumeration不具有fail-fast特性。

Note that the fail-fast behavior of an iterator cannot be guaranteed as it is, generally speaking, impossible to make any hard guarantees in the presence of unsynchronized concurrent modification. Fail-fast iterators throw ConcurrentModificationException on a best-effort basis. Therefore, it would be wrong to write a program that depended on this exception for its correctness: the fail-fast behavior of iterators should be used only to detect bugs. 注意迭代器的fail-fast特性不能保证,正如在非同步化修改中做保证也是不可能的。 具有fail-fast特性的迭代器会基于最有效原则抛出 ConcurrentModificationException, 因此写的程序依赖于该异常来纠正是错误的:迭代器的fail-fast特性应该只用来调试bug。

This class is a member of the Java Collections Framework. 该接口是Java集合框架成员之一。

Since: JDK1.0 See Also: Collection, List, ArrayList, LinkedList, Serialized FormField Summary

protected int

capacityIncrement

The amount by which the capacity of the vector is automatically incremented when its size becomes greater than its capacity. 当vector的大小超出它的容量时,容量的自动增加量。

protected int

elementCount

The number of valid components in this Vector object. Vector对象的有效成员数。

protected Object[]

elementData

The array buffer into which the components of the vector are stored. 存储vector成员的数组缓冲。

Fields inherited from class java.util.AbstractList

modCount

Constructor Summary

Vector()

Constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero. 构造一个空vector,内部数据数组大小为10,标准容量增长量为0。

Vector(Collection c)

Constructs a vector containing the elements of the specified collection, in the order they are returned by the collection's iterator. 构造一个vector,包含指定集合的元素,顺序为集合迭代器的返回顺序。

Vector(int initialCapacity)

Constructs an empty vector with the specified initial capacity and with its capacity increment equal to zero. 构造一个空vector,指定初始容量,标准容量增长量为0。

Vector(int initialCapacity, int capacityIncrement)

Constructs an empty vector with the specified initial capacity and capacity increment. 构造一个空vector,指定初始容量和标准容量增长量。

Method Summary

void

add(int index, Object element)

Inserts the specified element at the specified position in this Vector. 向Vector指定位置插入指定元素。

boolean

add(Object o)

Appends the specified element to the end of this Vector. 向Vector末尾添加指定元素。

boolean

addAll(Collection c)

Appends all of the elements in the specified Collection to the end of this Vector, in the order that they are returned by the specified Collection's Iterator. 向Vector尾部追加指定集合的所有元素,以指定集合的Iterator返回顺序为序。

boolean

addAll(int index, Collection c)

Inserts all of the elements in in the specified Collection into this Vector at the specified position. 向Vector指定位置插入指定Collection的所有元素。

void

addElement(Object obj)

Adds the specified component to the end of this vector, increasing its size by one. 向Vector末尾添加指定元素,大小加1。

int

capacity()

Returns the current capacity of this vector. 返回当前vector的容量。

void

clear()

Removes all of the elements from this Vector. 从Vector中删除所有元素。

Object

clone()

Returns a clone of this vector. 返回vector的克隆。

boolean

contains(Object elem)

Tests if the specified object is a component in this vector. 测试指定对象是否是vector的成员。

boolean

containsAll(Collection c)

Returns true if this Vector contains all of the elements in the specified Collection. 如果Vector包含指定集合的所有元素,返回true。

void

)]copyInto(Object[] anArray)

Copies the components of this vector into the specified array. 向指定数组拷贝vector的成员。

Object

elementAt(int index)

Returns the component at the specified index. 返回指定下标的成员。

Enumeration

elements()

Returns an enumeration of the components of this vector. 返回vector的成员枚举。

void

ensureCapacity(int minCapacity)

Increases the capacity of this vector, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument. 增加vector的容量,确保能容纳由minCapacity参数指定的成员数量。

boolean

equals(Object o)

Compares the specified Object with this Vector for equality. 将指定对象和当前Vector比较相等性。

Object

firstElement()

Returns the first component (the item at index 0) of this vector. 返回vector的第一个成员(下标为0)。

Object

get(int index)

Returns the element at the specified position in this Vector. 返回Vector中指定位置的元素。

int

hashCode()

Returns the hash code value for this Vector. 返回Vector的哈希码值。

int

indexOf(Object elem)

Searches for the first occurence of the given argument, testing for equality using the equals method. 查找指定参数第一次出现的位置,使用equals方法测试相等性。

int

indexOf(Object elem, int index)

Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method. 由下标index开始查找指定参数第一次出现的位置,使用equals方法测试相等性。

void

insertElementAt(Object obj, int index)

Inserts the specified object as a component in this vector at the specified index. 以指定对象为成员插入vector指定下标位置处。

boolean

isEmpty()

Tests if this vector has no components. 测试vector是否没有成员。

Object

lastElement()

Returns the last component of the vector. 返回vector的最后一个成员。

int

lastIndexOf(Object elem)

Returns the index of the last occurrence of the specified object in this vector. 返回vector中指定对象最后一次出现的下标。

int

lastIndexOf(Object elem, int index)

Searches backwards for the specified object, starting from the specified index, and returns an index to it. 由指定下标开始,向后查找指定对象,返回对象的下标。

Object

remove(int index)

Removes the element at the specified position in this Vector. 从Vector中删除指定位置的元素。

boolean

remove(Object o)

Removes the first occurrence of the specified element in this Vector If the Vector does not contain the element, it is unchanged. 从Vector中删除第一个出现的指定元素。如果不含该元素,Vector不变。

boolean

removeAll(Collection c)

Removes from this Vector all of its elements that are contained in the specified Collection. 从Vector中删除指定集合包含的所有元素。

void

removeAllElements()

Removes all components from this vector and sets its size to zero. 删除vector的所有成员,大小设为0。

boolean

removeElement(Object obj)

Removes the first (lowest-indexed) occurrence of the argument from this vector. 从vector中删除第一个(下标最小)出现的参数。

void

removeElementAt(int index)

Deletes the component at the specified index. 删除指定下标的成员。

protected void

removeRange(int fromIndex, int toIndex)

Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive. 从List中删除下标在fromIndex(含)和toIndex(不含)之间的所有元素。

boolean

retainAll(Collection c)

Retains only the elements in this Vector that are contained in the specified Collection. 使Vector只保留指定集合中所含的元素。

Object

set(int index, Object element)

Replaces the element at the specified position in this Vector with the specified element. 用指定元素替换Vector指定位置的元素。

void

setElementAt(Object obj, int index)

Sets the component at the specified index of this vector to be the specified object. 将vector指定下标的成员设为指定对象。

void

setSize(int newSize)

Sets the size of this vector. 设置vector的大小。

int

size()

Returns the number of components in this vector. 返回vector的成员数量。

List

subList(int fromIndex, int toIndex)

Returns a view of the portion of this List between fromIndex, inclusive, and toIndex, exclusive. 返回List中下标在fromIndex(含)和toIndex(不含)之间的元素视图。

Object[]

toArray()

Returns an array containing all of the elements in this Vector in the correct order. 返回一个数组,以正确的顺序包含Vector的所有元素。

Object[]

)]toArray(Object[] a)

Returns an array containing all of the elements in this Vector in the correct order; the runtime type of the returned array is that of the specified array. 返回一个数组,以正确的顺序包含Vector的所有元素,返回数组的运行时类型为指定数组的类型。

String

toString()

Returns a string representation of this Vector, containing the String representation of each element. 返回Vector的字符串形式,包含每一个元素的字符串形式。

void

trimToSize()

Trims the capacity of this vector to be the vector's current size. 将vector的容量调整为vector的当前大小。

Methods inherited from class java.util.AbstractList

iterator, listIterator, listIterator

Methods inherited from class java.lang.Object

finalize, getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.List

iterator, listIterator, listIterator

Field Detail

elementDataprotected Object[] elementData

The array buffer into which the components of the vector are stored. The capacity of the vector is the length of this array buffer, and is at least large enough to contain all the vector's elements. 存储vector成员的数组缓冲。vector的容量为数组缓冲的长度,至少应能容纳vector的所有元素。 Any array elements following the last element in the Vector are null. 紧随Vector最后一个元素的任意数组元素为null。

elementCountprotected int elementCount

The number of valid components in this Vector object. Components elementData[0] through elementData[elementCount-1] are the actual items. Vector对象的有效成员数。成员elementData[0]到elementData[elementCount-1]是现有的项。

capacityIncrementprotected int capacityIncrement

The amount by which the capacity of the vector is automatically incremented when its size becomes greater than its capacity. If the capacity increment is less than or equal to zero, the capacity of the vector is doubled each time it needs to grow. 当vector的大小超出它的容量时,容量的自动增加量。如果容量增加量小于等于0, 那么每次当vector需要增长时容量翻倍。

Constructor Detail

Vectorpublic Vector(int initialCapacity,

int capacityIncrement)

Constructs an empty vector with the specified initial capacity and capacity increment. 构造一个空vector,指定初始容量和标准容量增长量。

Parameters: initialCapacity - the initial capacity of the vector. vector的初始容量。 capacityIncrement - the amount by which the capacity is increased when the vector overflows. 当vector填满时增加的容量值。 Throws: IllegalArgumentException - if the specified initial capacity is negative 如果指定初始容量为负时抛出Vectorpublic Vector(int initialCapacity)

Constructs an empty vector with the specified initial capacity and with its capacity increment equal to zero. 构造一个空vector,指定初始容量,标准容量增长量为0。

Parameters: initialCapacity - the initial capacity of the vector. vector的初始容量。 Throws: IllegalArgumentException - if the specified initial capacity is negative 如果指定初始容量为负时抛出Vectorpublic Vector()

Constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero. 构造一个空vector,内部数据数组大小为10,标准容量增长量为0。

Vectorpublic Vector(Collection c)

Constructs a vector containing the elements of the specified collection, in the order they are returned by the collection's iterator. 构造一个vector,包含指定集合的元素,顺序为集合迭代器的返回顺序。

Parameters: c - the collection whose elements are to be placed into this vector. 被放入vector的元素集合。 Throws: NullPointerException - if the specified collection is null.] 如果指定集合为null时抛出。 Since: 1.2 Method Detail

copyIntopublic void copyInto(Object[] anArray)

Copies the components of this vector into the specified array. The item at index k in this vector is copied into component k of anArray. The array must be big enough to hold all the objects in this vector, else an IndexOutOfBoundsException is thrown. 向指定数组拷贝vector的成员。vector中下标k处的项被拷贝至anArray的成员k。 数组必须足够大以能容纳vector中的所有对象,否则抛出IndexOutOfBoundsException。

Parameters: anArray - the array into which the components get copied. 成员被拷贝至的数组。 Throws: NullPointerException - if the given array is null. 如果指定数组为null时抛出。trimToSizepublic void trimToSize()

Trims the capacity of this vector to be the vector's current size. If the capacity of this vector is larger than its current size, then the capacity is changed to equal the size by replacing its internal data array, kept in the field elementData, with a smaller one. An application can use this operation to minimize the storage of a vector. 将vector的容量调整为vector的当前大小。如果vector的容量大于当前大小, 那么通过替换内部数据数组(由elementData域维护)来使得容量和大小相等。 应用程序可以使用该操作来减小vector的存储量。

ensureCapacitypublic void ensureCapacity(int minCapacity)

Increases the capacity of this vector, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument. 增加vector的容量,确保能容纳由minCapacity参数指定的成员数量。 If the current capacity of this vector is less than minCapacity, then its capacity is increased by replacing its internal data array, kept in the field elementData, with a larger one. The size of the new data array will be the old size plus capacityIncrement, unless the value of capacityIncrement is less than or equal to zero, in which case the new capacity will be twice the old capacity; but if this new size is still smaller than minCapacity, then the new capacity will be minCapacity. 如果vector的当前容量小于minCapacity,那么通过替换其内部数据数组(由elementData 维护)来增加其容量。数据数组的新的大小将是在旧的大小上加上capacityIncrement, 除非capacityIncrement值小于等于0,这种情况下新的容量将是旧容量的两倍, 但是如果新的大小仍然小于minCapacity,那么新的容量将是minCapacity。

Parameters: minCapacity - the desired minimum capacity. 期望的最小容量。setSizepublic void setSize(int newSize)

Sets the size of this vector. If the new size is greater than the current size, new null items are added to the end of the vector. If the new size is less than the current size, all components at index newSize and greater are discarded. 设置vector的大小。如果新的大小大于当前大小,那么向vector尾部添加新的null项。 如果新的大小小于当前大小,所有位于下标newSize和大于该下标的成员全都被丢弃。

Parameters: newSize - the new size of this vector. vector新的大小。 Throws: ArrayIndexOutOfBoundsException - if new size is negative.capacitypublic int capacity()

Returns the current capacity of this vector. 返回当前vector的容量。

Returns: the current capacity (the length of its internal data array, kept in the field elementData of this vector). 当前容量(内部数据数组的长度,由vector的elementData域维护)。sizepublic int size()

Returns the number of components in this vector. 返回vector的成员数量。

Specified by: size in interface List Specified by: size in class AbstractCollectionReturns: the number of components in this vector. vector的成员数量。isEmptypublic boolean isEmpty()

Tests if this vector has no components. 测试vector是否没有成员。

Specified by: isEmpty in interface List Overrides: isEmpty in class AbstractCollectionReturns: true if and only if this vector has no components, that is, its size is zero; false otherwise. 只有当vector不含元素,即大小为0时,返回true;否则为false。elementspublic Enumeration elements()

Returns an enumeration of the components of this vector. The returned Enumeration object will generate all items in this vector. The first item generated is the item at index 0, then the item at index 1, and so on. 返回vector的成员枚举。返回的Enumeration对象将生成vector的所有项。生成的第一项 下标为0,第二项下标为1,以此类推。

Returns: an enumeration of the components of this vector. vector的成员枚举。 See Also: Enumeration, Iteratorcontainspublic boolean contains(Object elem)

Tests if the specified object is a component in this vector. 测试指定对象是否是vector的成员。

Specified by: contains in interface List Overrides: contains in class AbstractCollectionParameters: elem - an object. 一个对象。 Returns: true if and only if the specified object is the same as a component in this vector, as determined by the equals method; false otherwise. 只有当指定的对象和vector的一个成员相同(由equals方法确定)时返回true,否则返回false。indexOfpublic int indexOf(Object elem)

Searches for the first occurence of the given argument, testing for equality using the equals method. 查找指定参数第一次出现的位置,使用equals方法测试相等性。

Specified by: indexOf in interface List Overrides: indexOf in class AbstractListParameters: elem - an object. 对象。 Returns: the index of the first occurrence of the argument in this vector, that is, the smallest value k such that elem.equals(elementData[k]) is true; returns -1 if the object is not found. 参数在vector中第一次出现的位置,即使得elem.equals(elementData[k])为true的最小值k, 如果找不到该对象,返回-1。 See Also: Object.equals(Object)indexOfpublic int indexOf(Object elem,

int index)

Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method. 由下标index开始查找指定参数第一次出现的位置,使用equals方法测试相等性。

Parameters: elem - an object. index - the non-negative index to start searching from. Returns: the index of the first occurrence of the object argument in this vector at position index or later in the vector, that is, the smallest value k such that elem.equals(elementData[k]) && (k >= index) is true; returns -1 if the object is not found. (Returns -1 if index >= the current size of this Vector.) 对象参数在vector中从位置index开始第一次出现的位置,即使得elem.equals(elementData[k]) && (k >= index)为true的最小值k,如果找不到该对象,返回-1。 (如果index >= Vector的当前大小,返回-1。) Throws: IndexOutOfBoundsException - if index is negative. 如果index为负时抛出。 See Also: Object.equals(Object)lastIndexOfpublic int lastIndexOf(Object elem)

Returns the index of the last occurrence of the specified object in this vector. 返回vector中指定对象最后一次出现的下标。

Specified by: lastIndexOf in interface List Overrides: lastIndexOf in class AbstractListParameters: elem - the desired component. 期望成员。 Returns: the index of the last occurrence of the specified object in this vector, that is, the largest value k such that elem.equals(elementData[k]) is true; returns -1 if the object is not found. 指定对象在vector中最后一次出现的位置,即使得elem.equals(elementData[k])为true 的最大值k,如果找不到该对象,返回-1。lastIndexOfpublic int lastIndexOf(Object elem,

int index)

Searches backwards for the specified object, starting from the specified index, and returns an index to it. 由指定下标开始,向后查找指定对象,返回对象的下标。

Parameters: elem - the desired component. 期望成员。 index - the index to start searching from. 起始查找的下标。 Returns: the index of the last occurrence of the specified object in this vector at position less than or equal to index in the vector, that is, the largest value k such that elem.equals(elementData[k]) && (k <= index) is true; -1 if the object is not found. (Returns -1 if index is negative.) 对象参数在vector中从位置index开始最后一次出现的位置,即使得 elem.equals(elementData[k]) && (k <= index)为true的最大值k, 如果找不到该对象,返回-1。(如果index为负时,返回-1。) Throws: IndexOutOfBoundsException - if index is greater than or equal to the current size of this vector. 如果index大于等于vector的当前大小时抛出。elementAtpublic Object elementAt(int index)

Returns the component at the specified index. 返回指定下标的成员。 This method is identical in functionality to the get method (which is part of the List interface). 该方法和get方法(List接口的一部分)功能上一致。

Parameters: index - an index into this vector. vector的一个下标。 Returns: the component at the specified index. 指定下标的成员。 Throws: ArrayIndexOutOfBoundsException - if the index is negative or not less than the current size of this Vector object. 如果下标为负或者不小于当前Vector对象的大小时抛出。 given. See Also: get(int), ListfirstElementpublic Object firstElement()

Returns the first component (the item at index 0) of this vector. 返回vector的第一个成员(下标为0)。

Returns: the first component of this vector. vector的第一个成员。 Throws: NoSuchElementException - if this vector has no components. 如果vector没有成员时抛出。lastElementpublic Object lastElement()

Returns the last component of the vector. 返回vector的最后一个成员。

Returns: the last component of the vector, i.e., the component at index size() - 1. vector的最后一个成员,即下标为size() - 1的成员。 Throws: NoSuchElementException - if this vector is empty. 如果vector为空时抛出。setElementAtpublic void setElementAt(Object obj,

int index)

Sets the component at the specified index of this vector to be the specified object. The previous component at that position is discarded. 将vector指定下标的成员设为指定对象。该位置的原成员被丢弃。 The index must be a value greater than or equal to 0 and less than the current size of the vector. index应该大于等于0,而小于等于vector的当前大小。

This method is identical in functionality to the set method (which is part of the List interface). Note that the set method reverses the order of the parameters, to more closely match array usage. Note also that the set method returns the old value that was stored at the specified position. 该方法和set方法(List接口的一部分)功能上一致。注意:set方法颠倒了参数的顺序,更符合数组的用法。 set方法返回指定位置存储的旧值。

Parameters: obj - what the component is to be set to. 要被设置的成员。 index - the specified index. 指定的下标。 Throws: ArrayIndexOutOfBoundsException - if the index was invalid. 如果index无效时抛出。 See Also: size(), List, set(int, java.lang.Object)removeElementAtpublic void removeElementAt(int index)

Deletes the component at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted downward to have an index one smaller than the value it had previously. The size of this vector is decreased by 1. 删除指定下标的成员。vector中每一个下标大于指定index的成员均左移,下标值减1。 vector的大小减1。 The index must be a value greater than or equal to 0 and less than the current size of the vector. index应该大于等于0,而小于等于vector的当前大小。

This method is identical in functionality to the remove method (which is part of the List interface). Note that the remove method returns the old value that was stored at the specified position. 该方法和remove方法(List接口的一部分)功能上一致。注意:remove方法返回指定位置存储的旧值。

Parameters: index - the index of the object to remove. 要删除对象的下标。 Throws: ArrayIndexOutOfBoundsException - if the index was invalid. See Also: size(), remove(int), ListinsertElementAtpublic void insertElementAt(Object obj,

int index)

Inserts the specified object as a component in this vector at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously. 以指定对象为成员插入vector指定下标位置处。vector中每一个下标大于或等于指定的index 的成员均右移,下标值加1。 The index must be a value greater than or equal to 0 and less than or equal to the current size of the vector. (If the index is equal to the current size of the vector, the new element is appended to the Vector.) index应该大于等于0,而小于等于vector的当前大小。(如果index等于vector 的当前大小,新元素向Vector追加。)

This method is identical in functionality to the add(Object, int) method (which is part of the List interface). Note that the add method reverses the order of the parameters, to more closely match array usage. 该方法和add(Object, int)方法(List接口的一部分)功能上一致。注意: add方法颠倒了参数的顺序,更符合数组的用法。

Parameters: obj - the component to insert. 要插入的元素。 index - where to insert the new component. 要查入新成员的位置。 Throws: ArrayIndexOutOfBoundsException - if the index was invalid. 如果index无效时抛出。 See Also: size(), add(int, Object), ListaddElementpublic void addElement(Object obj)

Adds the specified component to the end of this vector, increasing its size by one. The capacity of this vector is increased if its size becomes greater than its capacity. 向Vector末尾添加指定元素,大小加1。如果vector的大小超出了它的容量,则容量增加。 This method is identical in functionality to the add(Object) method (which is part of the List interface). 该方法和add(Object)方法(List接口的一部分)功能上一致。

Parameters: obj - the component to be added. 要添加的成员。 See Also: add(Object), ListremoveElementpublic boolean removeElement(Object obj)

Removes the first (lowest-indexed) occurrence of the argument from this vector. If the object is found in this vector, each component in the vector with an index greater or equal to the object's index is shifted downward to have an index one smaller than the value it had previously. 从vector中删除第一个(下标最小)出现的参数。如果vector中找到该对象, 那么vector中每一个下标大于对象下标的成员均左移,下标值减1。 This method is identical in functionality to the remove(Object) method (which is part of the List interface). 该方法和remove(Object)方法(List接口的一部分)功能上一致。

Parameters: obj - the component to be removed. 要删除的元素。 Returns: true if the argument was a component of this vector; false otherwise. 如果参数是vector的一个成员,返回true,否则为false。 See Also: List.remove(Object), ListremoveAllElementspublic void removeAllElements()

Removes all components from this vector and sets its size to zero. 删除vector的所有成员,大小设为0。 This method is identical in functionality to the clear method (which is part of the List interface). 该方法和clear方法(List接口的一部分)功能上一致。

See Also: clear(), Listclonepublic Object clone()

Returns a clone of this vector. The copy will contain a reference to a clone of the internal data array, not a reference to the original internal data array of this Vector object. 返回vector的克隆。拷贝将包含内部数据数组克隆的引用,不包含当前Vector 对象中原有内部数据数组的引用。

Overrides: clone in class ObjectReturns: a clone of this vector. vector的克隆。 See Also: CloneabletoArraypublic Object[] toArray()

Returns an array containing all of the elements in this Vector in the correct order. 返回一个数组,以正确的顺序包含Vector的所有元素。

Specified by: toArray in interface List Overrides: toArray in class AbstractCollectionReturns: an array containing all of the elements in this collection. 包含集合所有元素的数组。 Since: 1.2 toArraypublic Object[] toArray(Object[] a)

Returns an array containing all of the elements in this Vector in the correct order; the runtime type of the returned array is that of the specified array. If the Vector fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this Vector. 返回一个数组,以正确的顺序包含Vector的所有元素,返回数组的运行时类型为指定数组的类型。 如果Vector可以填入指定数组,直接返回。否则使用指定数组的运行时类型和当前Vector 的大小创建一个新数组。 If the Vector fits in the specified array with room to spare (i.e., the array has more elements than the Vector), the element in the array immediately following the end of the Vector is set to null. This is useful in determining the length of the Vector only if the caller knows that the Vector does not contain any null elements. 如果当前Vector填入指定数组,空间上还有剩余(也就是Vector的元素比集合多), 那么数组中紧随集合后的元素都被设为null。只有当调用者知道Vector不包含null元素时, 确定Vector的长度才是有用的。

Specified by: )]toArray in interface List Overrides: )]toArray in class AbstractCollectionParameters: a - the array into which the elements of the Vector are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose. 存储Vector元素的数组,如果它足够大的话;否则为此创建一个运行时类型相同的新数组。 Returns: an array containing the elements of the Vector. 包含Vector元素的数组。 Throws: ArrayStoreException - the runtime type of a is not a supertype of the runtime type of every element in this Vector. 如果指定数组的运行时类型不是Vector中每个元素运行时类型的父一级类型时抛出。 NullPointerException - if the given array is null. 如果指定数组为null时抛出。 Since: 1.2 getpublic Object get(int index)

Returns the element at the specified position in this Vector. 返回Vector中指定位置的元素。

Specified by: get in interface List Specified by: get in class AbstractListParameters: index - index of element to return. 返回元素的下标。 Returns: object at the specified index 指定位置的对象 Throws: ArrayIndexOutOfBoundsException - index is out of range (index < 0 || index >= size()). 如果指定位置超出范围(index < 0 || index >= size())时抛出。 Since: 1.2 setpublic Object set(int index,

Object element)

Replaces the element at the specified position in this Vector with the specified element. 用指定元素替换Vector指定位置的元素。

Specified by: set in interface List Overrides: set in class AbstractListParameters: index - index of element to replace. 要替换的元素下标。 element - element to be stored at the specified position. 存储在指定位置的元素。 Returns: the element previously at the specified position. 指定位置的原元素。 Throws: ArrayIndexOutOfBoundsException - index out of range (index < 0 || index >= size()). 如果指定位置超出范围(index < 0 || index >= size())时抛出。 Since: 1.2 addpublic boolean add(Object o)

Appends the specified element to the end of this Vector. 向Vector末尾添加指定元素。

Specified by: add in interface List Overrides: add in class AbstractListParameters: o - element to be appended to this Vector. 要向Vector追加的元素。 Returns: true (as per the general contract of Collection.add). 根据Collection.add方法的一般约定返回true。 Since: 1.2 removepublic boolean remove(Object o)

Removes the first occurrence of the specified element in this Vector If the Vector does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists). 从Vector中删除第一个出现的指定元素。如果不含该元素,Vector不变。 正式表述为,如果存在那样的元素,使得(o==null ? get(i)==null : o.equals(get(i))), 那么删除下标i最小的元素。

Specified by: remove in interface List Overrides: remove in class AbstractCollectionParameters: o - element to be removed from this Vector, if present. 如果有,从Vector中删除的元素。 Returns: true if the Vector contained the specified element. 如果Vector包含指定元素,返回true。 Since: 1.2 addpublic void add(int index,

Object element)

Inserts the specified element at the specified position in this Vector. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). 向Vector指定位置插入指定元素。当前位置的元素(若有)和所有后续元素右移(下标加1)。

Specified by: add in interface List Overrides: add in class AbstractListParameters: index - index at which the specified element is to be inserted. 要插入指定元素的下标。 element - element to be inserted. 要插入的元素。 Throws: ArrayIndexOutOfBoundsException - index is out of range (index < 0 || index > size()). 位置超出范围(index < 0 || index > size())时抛出。 Since: 1.2 removepublic Object remove(int index)

Removes the element at the specified position in this Vector. shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the Vector. 从Vector中删除指定位置的元素。同时将所有后续元素左移(索引减1)。返回Vector中被删除的元素。

Specified by: remove in interface List Overrides: remove in class AbstractListParameters: index - the index of the element to removed. 要被删除的元素位置。 Returns: element that was removed 被删除的元素 Throws: ArrayIndexOutOfBoundsException - index out of range (index < 0 || index >= size()). 如果指定位置超出范围(index < 0 || index >= size())时抛出。 Since: 1.2 clearpublic void clear()

Removes all of the elements from this Vector. The Vector will be empty after this call returns (unless it throws an exception). 从Vector中删除所有元素。在调用返回后Vector将为空(除非抛出异常)。

Specified by: clear in interface List Overrides: clear in class AbstractListSince: 1.2 containsAllpublic boolean containsAll(Collection c)

Returns true if this Vector contains all of the elements in the specified Collection. 如果Vector包含指定集合的所有元素,返回true。

Specified by: containsAll in interface List Overrides: containsAll in class AbstractCollectionParameters: c - a collection whose elements will be tested for containment in this Vector 检查Vector是否包含的元素集合。 Returns: true if this Vector contains all of the elements in the specified collection. 如果Vector包含指定集合的所有元素,返回true。 Throws: NullPointerException - if the specified collection is null. 如果指定集合为null时抛出。 See Also: AbstractCollection.contains(Object)addAllpublic boolean addAll(Collection c)

Appends all of the elements in the specified Collection to the end of this Vector, in the order that they are returned by the specified Collection's Iterator. The behavior of this operation is undefined if the specified Collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified Collection is this Vector, and this Vector is nonempty.) 向Vector尾部追加指定集合的所有元素,以指定集合的Iterator返回顺序为序。 如果在该操作过程中指定集合被修改,操作行为无法确定。(这意味着如果指定集合是当前 Vector,且Vector不为空,则调用行为不能确定。)

Specified by: addAll in interface List Overrides: addAll in class AbstractCollectionParameters: c - elements to be inserted into this Vector. 被加入Vector的元素。 Returns: true if this Vector changed as a result of the call. 如果调用的结果改变了Vector,返回true。 Throws: NullPointerException - if the specified collection is null. 如果指定集合为null时抛出。 Since: 1.2 See Also: AbstractCollection.add(Object)removeAllpublic boolean removeAll(Collection c)

Removes from this Vector all of its elements that are contained in the specified Collection. 从Vector中删除指定集合包含的所有元素。

Specified by: removeAll in interface List Overrides: removeAll in class AbstractCollectionParameters: c - a collection of elements to be removed from the Vector 要从Vector中删除的元素集合 Returns: true if this Vector changed as a result of the call. 如果调用的结果改变了Vector,返回true。 Throws: NullPointerException - if the specified collection is null. 如果指定集合为null时抛出。 Since: 1.2 See Also: AbstractCollection.remove(Object), AbstractCollection.contains(Object)retainAllpublic boolean retainAll(Collection c)

Retains only the elements in this Vector that are contained in the specified Collection. In other words, removes from this Vector all of its elements that are not contained in the specified Collection. 使Vector只保留指定集合中所含的元素。换句话说,从列表中删除指定集合中不含的所有元素。

Specified by: retainAll in interface List Overrides: retainAll in class AbstractCollectionParameters: c - a collection of elements to be retained in this Vector (all other elements are removed) Vector要保留的元素集合(其它元素都删除)。 Returns: true if this Vector changed as a result of the call. 如果调用的结果改变了Vector,返回true。 Throws: NullPointerException - if the specified collection is null. 如果指定集合为null时抛出。 Since: 1.2 See Also: AbstractCollection.remove(Object), AbstractCollection.contains(Object)addAllpublic boolean addAll(int index,

Collection c)

Inserts all of the elements in in the specified Collection into this Vector at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the Vector in the order that they are returned by the specified Collection's iterator. 向Vector指定位置插入指定Collection的所有元素。当前位置的元素(若有) 和所有后续元素右移(下标加1)。Vector中新元素的出现顺序为指定集合迭代器返回的顺序。

Specified by: addAll in interface List Overrides: addAll in class AbstractListParameters: index - index at which to insert first element from the specified collection. 插入指定集合第一个元素的下标。 c - elements to be inserted into this Vector. 要插入Vector的元素。 Returns: true if this Vector changed as a result of the call. 如果调用的结果改变了Vector返回true。 Throws: ArrayIndexOutOfBoundsException - index out of range (index < 0 || index > size()). 位置超出范围(index < 0 || index > size())时抛出。 NullPointerException - if the specified collection is null. 如果指定集合为null时抛出。 Since: 1.2 equalspublic boolean equals(Object o)

Compares the specified Object with this Vector for equality. Returns true if and only if the specified Object is also a List, both Lists have the same size, and all corresponding pairs of elements in the two Lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two Lists are defined to be equal if they contain the same elements in the same order. 将指定对象和当前Vector比较相等性。只有指定对象也是一个列表, 两个列表有着相同大小,两个列表中所有对应元素都相等时返回true。 (如果(e1==null ? e2==null : e1.equals(e2)),那么两个元素e1和e2相等。) 换句话说,两个列表只有以相同顺序包含相同的元素,才被认为相等。

Specified by: equals in interface List Overrides: equals in class AbstractListParameters: o - the Object to be compared for equality with this Vector. 同当前Vector比较相等性的对象。 Returns: true if the specified Object is equal to this Vector 如果指定的对象与当前Vector相等,返回truehashCodepublic int hashCode()

Returns the hash code value for this Vector. 返回Vector的哈希码值。

Specified by: hashCode in interface List Overrides: hashCode in class AbstractListReturns: the hash code value for this list. 列表的哈希码值。toStringpublic String toString()

Returns a string representation of this Vector, containing the String representation of each element. 返回Vector的字符串形式,包含每一个元素的字符串形式。

Overrides: toString in class AbstractCollectionReturns: a string representation of this collection. 集合的字符串形式。subListpublic List subList(int fromIndex,

int toIndex)

Returns a view of the portion of this List between fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and ToIndex are equal, the returned List is empty.) The returned List is backed by this List, so changes in the returned List are reflected in this List, and vice-versa. The returned List supports all of the optional List operations supported by this List. 返回List中下标在fromIndex(含)和toIndex(不含)之间的元素视图。 返回列表由当前列表得出,因此返回列表的非结构性更改会影响到当前列表。 返回列表支持当前列表支持的所有可选操作。 This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a List can be used as a range operation by operating on a subList view instead of a whole List. For example, the following idiom removes a range of elements from a List: 该方法克服了显式范围操作时需将列表转换成数组的弊端。 对于希望将列表用于范围操作的方法只需要传递给子列表视图代之整个列表。 例如,以下语法删除列表中某个范围的元素:

list.subList(from, to).clear();

Similar idioms may be constructed for indexOf and lastIndexOf, and all of the algorithms in the Collections class can be applied to a subList. 对于indexOf和lastIndexOf的用法相似,Collections类的所有算法 都可以在子列表中应用。 The semantics of the List returned by this method become undefined if the backing list (i.e., this List) is structurally modified in any way other than via the returned List. (Structural modifications are those that change the size of the List, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.) 如果返回列表通过某种方式使当前列表发生了结构性的改变,该方法返回的列表语义 将变得不能确定。(结构性的改变指改变列表的大小,或者在迭代过程中 以其它方式使得生成结果不正确。)

Specified by: subList in interface List Overrides: subList in class AbstractListParameters: fromIndex - low endpoint (inclusive) of the subList. 子表的起始端(含)。 toIndex - high endpoint (exclusive) of the subList. 子表的结束端(不含)。 Returns: a view of the specified range within this List. 指定范围的列表视图。 Throws: IndexOutOfBoundsException - endpoint index value out of range (fromIndex < 0 || toIndex > size) 端点位置超出范围(fromIndex < 0 || toIndex > size())时抛出 IllegalArgumentException - endpoint indices out of order (fromIndex > toIndex) 端点下标无序(fromIndex > toIndex) removeRangeprotected void removeRange(int fromIndex,

int toIndex)

Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive. Shifts any succeeding elements to the left (reduces their index). This call shortens the ArrayList by (toIndex - fromIndex) elements. (If toIndex==fromIndex, this operation has no effect.) 从List中删除下标在fromIndex(含)和toIndex(不含)之间的所有元素。左移所有后续元素(减小索引)。 调用将使ArrayList减少(toIndex - fromIndex)个元素。(如果toIndex==fromIndex,操作无效。)

Overrides: removeRange in class AbstractListParameters: fromIndex - index of first element to be removed. 要删除的第一个元素下标。 toIndex - index after last element to be removed. 要删除的最后一个元素之后的下标。 [/url][url=file:///F:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/overview-summary.html]Overview

Package

Class

Use

Tree

Deprecated

Index

Help

JavaTM 2 Platform

Std. Ed. v1.4.2

PREV CLASS NEXT CLASS

FRAMES NO FRAMES All Classes

SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature

For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
>>返回首页<<
推荐阅读
 
 
频道精选
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
© 2005- 王朝网络 版权所有