📄 vector.html
字号:
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.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>obj</CODE> - the component to insert.<DD><CODE>index</CODE> - where to insert the new component.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if the index was invalid.<DT><B>See Also: </B><DD><A HREF="../../java/util/Vector.html#size()"><CODE>size()</CODE></A>, <A HREF="../../java/util/Vector.html#add(int, java.lang.Object)"><CODE>add(int, Object)</CODE></A>, <A HREF="../../java/util/List.html"><CODE>List</CODE></A></DL></DD></DL><HR><A NAME="addElement(java.lang.Object)"><!-- --></A><H3>addElement</H3><PRE>public void <B>addElement</B>(<A HREF="../../java/lang/Object.html">Object</A> obj)</PRE><DL><DD>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. <p> This method is identical in functionality to the add(Object) method (which is part of the List interface).<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>obj</CODE> - the component to be added.<DT><B>See Also: </B><DD><A HREF="../../java/util/Vector.html#add(java.lang.Object)"><CODE>add(Object)</CODE></A>, <A HREF="../../java/util/List.html"><CODE>List</CODE></A></DL></DD></DL><HR><A NAME="removeElement(java.lang.Object)"><!-- --></A><H3>removeElement</H3><PRE>public boolean <B>removeElement</B>(<A HREF="../../java/lang/Object.html">Object</A> obj)</PRE><DL><DD>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.<p> This method is identical in functionality to the remove(Object) method (which is part of the List interface).<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>obj</CODE> - the component to be removed.<DT><B>Returns:</B><DD><code>true</code> if the argument was a component of this vector; <code>false</code> otherwise.<DT><B>See Also: </B><DD><A HREF="../../java/util/List.html#remove(java.lang.Object)"><CODE>List.remove(Object)</CODE></A>, <A HREF="../../java/util/List.html"><CODE>List</CODE></A></DL></DD></DL><HR><A NAME="removeAllElements()"><!-- --></A><H3>removeAllElements</H3><PRE>public void <B>removeAllElements</B>()</PRE><DL><DD>Removes all components from this vector and sets its size to zero.<p> This method is identical in functionality to the clear method (which is part of the List interface).<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../java/util/Vector.html#clear()"><CODE>clear()</CODE></A>, <A HREF="../../java/util/List.html"><CODE>List</CODE></A></DL></DD></DL><HR><A NAME="clone()"><!-- --></A><H3>clone</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A> <B>clone</B>()</PRE><DL><DD>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 <tt>Vector</tt> object.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#clone()">clone</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>a clone of this vector.</DL></DD></DL><HR><A NAME="toArray()"><!-- --></A><H3>toArray</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A>[] <B>toArray</B>()</PRE><DL><DD>Returns an array containing all of the elements in this Vector in the correct order.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#toArray()">toArray</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#toArray()">toArray</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="toArray(java.lang.Object[])"><!-- --></A><H3>toArray</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A>[] <B>toArray</B>(<A HREF="../../java/lang/Object.html">Object</A>[] a)</PRE><DL><DD>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.<p> 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 <em>only</em> if the caller knows that the Vector does not contain any null elements.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#toArray(java.lang.Object[])">toArray</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#toArray(java.lang.Object[])">toArray</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - 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.<DT><B>Returns:</B><DD>an array containing the elements of the Vector.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ArrayStoreException.html">ArrayStoreException</A></CODE> - the runtime type of a is not a supertype of the runtime type of every element in this Vector.</DL></DD></DL><HR><A NAME="get(int)"><!-- --></A><H3>get</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A> <B>get</B>(int index)</PRE><DL><DD>Returns the element at the specified position in this Vector.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#get(int)">get</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractList.html#get(int)">get</A></CODE> in class <CODE><A HREF="../../java/util/AbstractList.html">AbstractList</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>index</CODE> - index of element to return.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - index is out of range (index < 0 || index >= size()).<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="set(int, java.lang.Object)"><!-- --></A><H3>set</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A> <B>set</B>(int index, <A HREF="../../java/lang/Object.html">Object</A> element)</PRE><DL><DD>Replaces the element at the specified position in this Vector with the specified element.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#set(int, java.lang.Object)">set</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractList.html#set(int, java.lang.Object)">set</A></CODE> in class <CODE><A HREF="../../java/util/AbstractList.html">AbstractList</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>index</CODE> - index of element to replace.<DD><CODE>element</CODE> - element to be stored at the specified position.<DT><B>Returns:</B><DD>the element previously at the specified position.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - index out of range (index < 0 || index >= size()).<DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - fromIndex > toIndex.<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="add(java.lang.Object)"><!-- --></A><H3>add</H3><PRE>public boolean <B>add</B>(<A HREF="../../java/lang/Object.html">Object</A> o)</PRE><DL><DD>Appends the specified element to the end of this Vector.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#add(java.lang.Object)">add</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractList.html#add(java.lang.Object)">add</A></CODE> in class <CODE><A HREF="../../java/util/AbstractList.html">AbstractList</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - element to be appended to this Vector.<DT><B>Returns:</B><DD>true (as per the general contract of Collection.add).<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="remove(java.lang.Object)"><!-- --></A><H3>remove</H3><PRE>public boolean <B>remove</B>(<A HREF="../../java/lang/Object.html">Object</A> o)</PRE><DL><DD>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 <code>(o==null ? get(i)==null : o.equals(get(i)))</code> (if such an element exists).<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#remove(java.lang.Object)">remove</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#remove(java.lang.Object)">remove</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - element to be removed from this Vector, if present.<DT><B>Returns:</B><DD>true if the Vector contained the specified element.<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="add(int, java.lang.Object)"><!-- --></A><H3>add</H3><PRE>public void <B>add</B>(int index, <A HREF="../../java/lang/Object.html">Object</A> element)</PRE><DL><DD>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).<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#add(int, java.lang.Object)">add</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractList.html#add(int, java.lang.Object)">add</A></CODE> in class <CODE><A HREF="../../java/util/AbstractList.html">AbstractList</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>index</CODE> - index at which the specified element is to be inserted.<DD><CODE>element</CODE> - element to be inserted.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - index is out of range (index < 0 || index > size()).<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="remove(int)"><!-- --></A><H3>remove</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A> <B>remove</B>(int index)</PRE><DL><DD>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.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#remove(int)">remove</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractList.html#remove(int)">remove</A></CODE> in class <CODE><A HREF="../../java/util/AbstractList.html">AbstractList</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>index</CODE> - the index of the element to removed.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - index out of range (index < 0 || index >= size()).<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="clear()"><!-- --></A><H3>clear</H3><PRE>public void <B>clear</B>()</PRE><DL><DD>Removes all of the elements from this Vector. The Vector will be empty after this call returns (unless it throws an exception).<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#clear()">clear</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractList.html#clear()">clear</A></CODE> in class <CODE><A HREF="../../java/util/AbstractList.html">AbstractList</A></CODE></DL></DD><DD><DL><DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="containsAll(java.util.Collection)"><!-- --></A><H3>containsAll</H3><PRE>public boolean <B>containsAll</B>(<A HREF="../../java/util/Collection.html">Collection</A> c)</PRE><DL><DD>Returns true if this Vector contains all of the elements in the specified Collection.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#containsAll(java.util.Collection)">containsAll</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#containsAll(java.util.Collection)">containsAll</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>true if this Vector contains all of the elements in the specified collection.</DL></DD></D
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -