📄 arraylist.html
字号:
Searches for the first occurence of the given argument, testing for equality using the <tt>equals</tt> method.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/ArrayList.html#isEmpty()">isEmpty</A></B>()</CODE><BR> Tests if this list has no elements.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/ArrayList.html#lastIndexOf(java.lang.Object)">lastIndexOf</A></B>(<A HREF="../../java/lang/Object.html">Object</A> elem)</CODE><BR> Returns the index of the last occurrence of the specified object in this list.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/ArrayList.html#remove(int)">remove</A></B>(int index)</CODE><BR> Removes the element at the specified position in this list.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/ArrayList.html#removeRange(int, int)">removeRange</A></B>(int fromIndex, int toIndex)</CODE><BR> Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/ArrayList.html#set(int, java.lang.Object)">set</A></B>(int index, <A HREF="../../java/lang/Object.html">Object</A> element)</CODE><BR> Replaces the element at the specified position in this list with the specified element.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/ArrayList.html#size()">size</A></B>()</CODE><BR> Returns the number of elements in this list.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/Object.html">Object</A>[]</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/ArrayList.html#toArray()">toArray</A></B>()</CODE><BR> Returns an array containing all of the elements in this list in the correct order.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/Object.html">Object</A>[]</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/ArrayList.html#toArray(java.lang.Object[])">toArray</A></B>(<A HREF="../../java/lang/Object.html">Object</A>[] a)</CODE><BR> Returns an array containing all of the elements in this list in the correct order.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/ArrayList.html#trimToSize()">trimToSize</A></B>()</CODE><BR> Trims the capacity of this <tt>ArrayList</tt> instance to be the list's current size.</TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.util.AbstractList"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.util.<A HREF="../../java/util/AbstractList.html">AbstractList</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/util/AbstractList.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/util/AbstractList.html#hashCode()">hashCode</A>, <A HREF="../../java/util/AbstractList.html#iterator()">iterator</A>, <A HREF="../../java/util/AbstractList.html#listIterator()">listIterator</A>, <A HREF="../../java/util/AbstractList.html#listIterator(int)">listIterator</A>, <A HREF="../../java/util/AbstractList.html#subList(int, int)">subList</A></CODE></TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.util.AbstractCollection"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.util.<A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/util/AbstractCollection.html#containsAll(java.util.Collection)">containsAll</A>, <A HREF="../../java/util/AbstractCollection.html#remove(java.lang.Object)">remove</A>, <A HREF="../../java/util/AbstractCollection.html#removeAll(java.util.Collection)">removeAll</A>, <A HREF="../../java/util/AbstractCollection.html#retainAll(java.util.Collection)">retainAll</A>, <A HREF="../../java/util/AbstractCollection.html#toString()">toString</A></CODE></TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.lang.<A HREF="../../java/lang/Object.html">Object</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/lang/Object.html#finalize()">finalize</A>, <A HREF="../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../java/lang/Object.html#wait(long)">wait</A>, <A HREF="../../java/lang/Object.html#wait(long, int)">wait</A></CODE></TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.util.List"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from interface java.util.<A HREF="../../java/util/List.html">List</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/util/List.html#containsAll(java.util.Collection)">containsAll</A>, <A HREF="../../java/util/List.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/util/List.html#hashCode()">hashCode</A>, <A HREF="../../java/util/List.html#iterator()">iterator</A>, <A HREF="../../java/util/List.html#listIterator()">listIterator</A>, <A HREF="../../java/util/List.html#listIterator(int)">listIterator</A>, <A HREF="../../java/util/List.html#remove(java.lang.Object)">remove</A>, <A HREF="../../java/util/List.html#removeAll(java.util.Collection)">removeAll</A>, <A HREF="../../java/util/List.html#retainAll(java.util.Collection)">retainAll</A>, <A HREF="../../java/util/List.html#subList(int, int)">subList</A></CODE></TD></TR></TABLE> <P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="ArrayList(int)"><!-- --></A><H3>ArrayList</H3><PRE>public <B>ArrayList</B>(int initialCapacity)</PRE><DL><DD>Constructs an empty list with the specified initial capacity.<DD><DL><DT><B>Parameters:</B><DD><CODE>initialCapacity</CODE> - the initial capacity of the list.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the specified initial capacity is negative</DL></DD></DL><HR><A NAME="ArrayList()"><!-- --></A><H3>ArrayList</H3><PRE>public <B>ArrayList</B>()</PRE><DL><DD>Constructs an empty list.</DL><HR><A NAME="ArrayList(java.util.Collection)"><!-- --></A><H3>ArrayList</H3><PRE>public <B>ArrayList</B>(<A HREF="../../java/util/Collection.html">Collection</A> c)</PRE><DL><DD>Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator. The <tt>ArrayList</tt> instance has an initial capacity of 110% the size of the specified collection.<DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - the collection whose elements are to be placed into this list.</DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="trimToSize()"><!-- --></A><H3>trimToSize</H3><PRE>public void <B>trimToSize</B>()</PRE><DL><DD>Trims the capacity of this <tt>ArrayList</tt> instance to be the list's current size. An application can use this operation to minimize the storage of an <tt>ArrayList</tt> instance.<DD><DL></DL></DD></DL><HR><A NAME="ensureCapacity(int)"><!-- --></A><H3>ensureCapacity</H3><PRE>public void <B>ensureCapacity</B>(int minCapacity)</PRE><DL><DD>Increases the capacity of this <tt>ArrayList</tt> instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>minCapacity</CODE> - the desired minimum capacity.</DL></DD></DL><HR><A NAME="size()"><!-- --></A><H3>size</H3><PRE>public int <B>size</B>()</PRE><DL><DD>Returns the number of elements in this list.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#size()">size</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#size()">size</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the number of elements in this list.</DL></DD></DL><HR><A NAME="isEmpty()"><!-- --></A><H3>isEmpty</H3><PRE>public boolean <B>isEmpty</B>()</PRE><DL><DD>Tests if this list has no elements.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#isEmpty()">isEmpty</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#isEmpty()">isEmpty</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD><tt>true</tt> if this list has no elements; <tt>false</tt> otherwise.</DL></DD></DL><HR><A NAME="contains(java.lang.Object)"><!-- --></A><H3>contains</H3><PRE>public boolean <B>contains</B>(<A HREF="../../java/lang/Object.html">Object</A> elem)</PRE><DL><DD>Returns <tt>true</tt> if this list contains the specified element.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#contains(java.lang.Object)">contains</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#contains(java.lang.Object)">contains</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>elem</CODE> - element whose presence in this List is to be tested.</DL></DD></DL><HR><A NAME="indexOf(java.lang.Object)"><!-- --></A><H3>indexOf</H3><PRE>public int <B>indexOf</B>(<A HREF="../../java/lang/Object.html">Object</A> elem)</PRE><DL><DD>Searches for the first occurence of the given argument, testing for equality using the <tt>equals</tt> method.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#indexOf(java.lang.Object)">indexOf</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#indexOf(java.lang.Object)">indexOf</A></CODE> in class <CODE><A HREF="../../java/util/AbstractList.html">AbstractList</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>elem</CODE> - an object.<DT><B>Returns:</B><DD>the index of the first occurrence of the argument in this list; returns <tt>-1</tt> if the object is not found.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Object.html#equals(java.lang.Object)"><CODE>Object.equals(Object)</CODE></A></DL></DD></DL><HR><A NAME="lastIndexOf(java.lang.Object)"><!-- --></A><H3>lastIndexOf</H3><PRE>public int <B>lastIndexOf</B>(<A HREF="../../java/lang/Object.html">Object</A> elem)</PRE><DL><DD>Returns the index of the last occurrence of the specified object in this list.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#lastIndexOf(java.lang.Object)">lastIndexOf</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#lastIndexOf(java.lang.Object)">lastIndexOf</A></CODE> in class <CODE><A HREF="../../java/util/AbstractList.html">AbstractList</A></CODE></DL>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -