📄 abstractcollection.html
字号:
<BR> Returns an array containing all of the elements in this collection.</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/AbstractCollection.html#toArray(java.lang.Object[])">toArray</A></B>(<A HREF="../../java/lang/Object.html">Object</A>[] a)</CODE><BR> Returns an array with a runtime type is that of the specified array and that contains all of the elements in this collection.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/AbstractCollection.html#toString()">toString</A></B>()</CODE><BR> Returns a string representation of this collection.</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#clone()">clone</A>, <A HREF="../../java/lang/Object.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/lang/Object.html#finalize()">finalize</A>, <A HREF="../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../java/lang/Object.html#hashCode()">hashCode</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.Collection"><!-- --></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/Collection.html">Collection</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/util/Collection.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/util/Collection.html#hashCode()">hashCode</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="AbstractCollection()"><!-- --></A><H3>AbstractCollection</H3><PRE>protected <B>AbstractCollection</B>()</PRE><DL><DD>Sole constructor. (For invocation by subclass constructors, typically implicit.)</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="iterator()"><!-- --></A><H3>iterator</H3><PRE>public abstract <A HREF="../../java/util/Iterator.html">Iterator</A> <B>iterator</B>()</PRE><DL><DD>Returns an iterator over the elements contained in this collection.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Collection.html#iterator()">iterator</A></CODE> in interface <CODE><A HREF="../../java/util/Collection.html">Collection</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>an iterator over the elements contained in this collection.</DL></DD></DL><HR><A NAME="size()"><!-- --></A><H3>size</H3><PRE>public abstract int <B>size</B>()</PRE><DL><DD>Returns the number of elements in this collection. If the collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns <tt>Integer.MAX_VALUE</tt>.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Collection.html#size()">size</A></CODE> in interface <CODE><A HREF="../../java/util/Collection.html">Collection</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the number of elements in this collection.</DL></DD></DL><HR><A NAME="isEmpty()"><!-- --></A><H3>isEmpty</H3><PRE>public boolean <B>isEmpty</B>()</PRE><DL><DD>Returns <tt>true</tt> if this collection contains no elements.<p> This implementation returns <tt>size() == 0</tt>.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Collection.html#isEmpty()">isEmpty</A></CODE> in interface <CODE><A HREF="../../java/util/Collection.html">Collection</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD><tt>true</tt> if this collection contains no elements.</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> o)</PRE><DL><DD>Returns <tt>true</tt> if this collection contains the specified element. More formally, returns <tt>true</tt> if and only if this collection contains at least one element <tt>e</tt> such that <tt>(o==null ? e==null : o.equals(e))</tt>.<p> This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Collection.html#contains(java.lang.Object)">contains</A></CODE> in interface <CODE><A HREF="../../java/util/Collection.html">Collection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - object to be checked for containment in this collection.<DT><B>Returns:</B><DD><tt>true</tt> if this collection contains the specified element.</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 collection. If the collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. The returned array will be "safe" in that no references to it are maintained by the collection. (In other words, this method must allocate a new array even if the collection is backed by an Array). The caller is thus free to modify the returned array.<p> This implementation allocates the array to be returned, and iterates over the elements in the collection, storing each object reference in the next consecutive element of the array, starting with element 0.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Collection.html#toArray()">toArray</A></CODE> in interface <CODE><A HREF="../../java/util/Collection.html">Collection</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>an array containing all of the elements in this collection.</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 with a runtime type is that of the specified array and that contains all of the elements in this collection. If the collection 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 collection.<p> If the collection fits in the specified array with room to spare (i.e., the array has more elements than the collection), 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 collection <i>only</i> if the caller knows that the collection does not contain any <tt>null</tt> elements.)<p> If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. <p> This implementation checks if the array is large enough to contain the collection; if not, it allocates a new array of the correct size and type (using reflection). Then, it iterates over the collection, storing each object reference in the next consecutive element of the array, starting with element 0. If the array is larger than the collection, a <tt>null</tt> is stored in the first location after the end of the collection.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Collection.html#toArray(java.lang.Object[])">toArray</A></CODE> in interface <CODE><A HREF="../../java/util/Collection.html">Collection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - the array into which the elements of the collection 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 collection.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if the specified array is <tt>null</tt>.<DD><CODE><A HREF="../../java/lang/ArrayStoreException.html">ArrayStoreException</A></CODE> - if the runtime type of the specified array is not a supertype of the runtime type of every element in this collection.</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>Ensures that this collection contains the specified element (optional operation). Returns <tt>true</tt> if the collection changed as a result of the call. (Returns <tt>false</tt> if this collection does not permit duplicates and already contains the specified element.) Collections that support this operation may place limitations on what elements may be added to the collection. In particular, some collections will refuse to add <tt>null</tt> elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.<p> This implementation always throws an <tt>UnsupportedOperationException</tt>.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Collection.html#add(java.lang.Object)">add</A></CODE> in interface <CODE><A HREF="../../java/util/Collection.html">Collection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - element whose presence in this collection is to be ensured.<DT><B>Returns:</B><DD><tt>true</tt> if the collection changed as a result of the call.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the <tt>add</tt> method is not supported by this collection.<DD><CODE><A HREF="../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if this collection does not permit <tt>null</tt> elements, and the specified element is <tt>null</tt>.<DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the class of the specified element prevents it from being added to this collection.<DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if some aspect of this element prevents it from being added to this collection.</DL></DD></DL><HR><A NAME="remove(java.lang.Object)"><!-- --></A><H3>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -