📄 arraylist.html
字号:
</DD><DD><DL><DT><B>Parameters:</B><DD><CODE>elem</CODE> - the desired element.<DT><B>Returns:</B><DD>the index of the last occurrence of the specified object in this list; returns -1 if the object is not found.</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 shallow copy of this <tt>ArrayList</tt> instance. (The elements themselves are not copied.)<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 <tt>ArrayList</tt> instance.</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 list 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>Returns:</B><DD>an array containing all of the elements in this list in the correct order.</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 list in the correct order. The runtime type of the returned array is that of the specified array. If the list 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 list.<p> If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the collection is set to <tt>null</tt>. This is useful in determining the length of the list <i>only</i> if the caller knows that the list does not contain any <tt>null</tt> 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 list 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 list.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ArrayStoreException.html">ArrayStoreException</A></CODE> - if the runtime type of a is not a supertype of the runtime type of every element in this list.</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 list.<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>Returns:</B><DD>the element at the specified position in this list.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if index is out of range <tt>(index < 0 || index >= size())</tt>.</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 list 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/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if index out of range <tt>(index < 0 || index >= size())</tt>.</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 list.<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 list.<DT><B>Returns:</B><DD><tt>true</tt> (as per the general contract of Collection.add).</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 list. 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/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if index is out of range <tt>(index < 0 || index > size())</tt>.</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 list. Shifts any subsequent elements to the left (subtracts one from their indices).<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>Returns:</B><DD>the element that was removed from the list.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if index out of range <tt>(index < 0 || index >= size())</tt>.</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 list. The list will be empty after this call returns.<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>Following copied from interface: <CODE>java.util.List</CODE></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the <tt>clear</tt> method is not supported by this list.</DL></DD></DL><HR><A NAME="addAll(java.util.Collection)"><!-- --></A><H3>addAll</H3><PRE>public boolean <B>addAll</B>(<A HREF="../../java/util/Collection.html">Collection</A> c)</PRE><DL><DD>Appends all of the elements in the specified Collection to the end of this list, 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 list, and this list is nonempty.)<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#addAll(java.util.Collection)">addAll</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#addAll(java.util.Collection)">addAll</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - the elements to be inserted into this list.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if index out of range <tt>(index < 0 || index > size())</tt>.</DL></DD></DL><HR><A NAME="addAll(int, java.util.Collection)"><!-- --></A><H3>addAll</H3><PRE>public boolean <B>addAll</B>(int index, <A HREF="../../java/util/Collection.html">Collection</A> c)</PRE><DL><DD>Inserts all of the elements in the specified Collection into this list, starting 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 list in the order that they are returned by the specified Collection's iterator.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#addAll(int, java.util.Collection)">addAll</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#addAll(int, java.util.Collection)">addAll</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 to insert first element from the specified collection.<DD><CODE>c</CODE> - elements to be inserted into this list.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if index out of range <tt>(index < 0 || index > size())</tt>.</DL></DD></DL><HR><A NAME="removeRange(int, int)"><!-- --></A><H3>removeRange</H3><PRE>protected void <B>removeRange</B>(int fromIndex, int toIndex)</PRE><DL><DD>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 list by <tt>(toIndex - fromIndex)</tt> elements. (If <tt>toIndex==fromIndex</tt>, this operation has no effect.)<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractList.html#removeRange(int, int)">removeRange</A></CODE> in class <CODE><A HREF="../../java/util/AbstractList.html">AbstractList</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>fromIndex</CODE> - index of first element to be removed.<DD><CODE>toIndex</CODE> - index after last element to be removed.</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/ArrayList.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../java/util/AbstractSet.html"><B>PREV CLASS</B></A> <A HREF="../../java/util/Arrays.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="ArrayList.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#fields_inherited_from_class_java.util.AbstractList">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -