📄 abstractcollection.html
字号:
remove</H3><PRE>public boolean <B>remove</B>(<A HREF="../../java/lang/Object.html">Object</A> o)</PRE><DL><DD>Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an element <tt>e</tt> such that <tt>(o==null ? e==null : o.equals(e))</tt>, if the collection contains one or more such elements. Returns <tt>true</tt> if the collection contained the specified element (or equivalently, if the collection changed as a result of the call).<p> This implementation iterates over the collection looking for the specified element. If it finds the element, it removes the element from the collection using the iterator's remove method.<p> Note that this implementation throws an <tt>UnsupportedOperationException</tt> if the iterator returned by this collection's iterator method does not implement the <tt>remove</tt> method.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Collection.html#remove(java.lang.Object)">remove</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 to be removed from this collection, if present.<DT><B>Returns:</B><DD><tt>true</tt> if the collection contained the specified element.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the <tt>remove</tt> method is not supported by this collection.</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 <tt>true</tt> if this collection contains all of the elements in the specified collection. <p> This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection. If all elements are so contained <tt>true</tt> is returned, otherwise <tt>false</tt>.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Collection.html#containsAll(java.util.Collection)">containsAll</A></CODE> in interface <CODE><A HREF="../../java/util/Collection.html">Collection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - collection to be checked for containment in this collection.<DT><B>Returns:</B><DD><tt>true</tt> if this collection contains all of the elements in the specified collection.<DT><B>See Also: </B><DD><A HREF="../../java/util/AbstractCollection.html#contains(java.lang.Object)"><CODE>contains(Object)</CODE></A></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>Adds all of the elements in the specified collection to this collection (optional operation). 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 collection, and this collection is nonempty.) <p> This implementation iterates over the specified collection, and adds each object returned by the iterator to this collection, in turn.<p> Note that this implementation will throw an <tt>UnsupportedOperationException</tt> unless <tt>add</tt> is overridden.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Collection.html#addAll(java.util.Collection)">addAll</A></CODE> in interface <CODE><A HREF="../../java/util/Collection.html">Collection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - collection whose elements are to be added to this collection.<DT><B>Returns:</B><DD><tt>true</tt> if this 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>addAll</tt> method is not supported by this collection.<DT><B>See Also: </B><DD><A HREF="../../java/util/AbstractCollection.html#add(java.lang.Object)"><CODE>add(Object)</CODE></A></DL></DD></DL><HR><A NAME="removeAll(java.util.Collection)"><!-- --></A><H3>removeAll</H3><PRE>public boolean <B>removeAll</B>(<A HREF="../../java/util/Collection.html">Collection</A> c)</PRE><DL><DD>Removes from this collection all of its elements that are contained in the specified collection (optional operation). <p> This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's so contained, it's removed from this collection with the iterator's <tt>remove</tt> method.<p> Note that this implementation will throw an <tt>UnsupportedOperationException</tt> if the iterator returned by the <tt>iterator</tt> method does not implement the <tt>remove</tt> method.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Collection.html#removeAll(java.util.Collection)">removeAll</A></CODE> in interface <CODE><A HREF="../../java/util/Collection.html">Collection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - elements to be removed from this collection.<DT><B>Returns:</B><DD><tt>true</tt> if this collection changed as a result of the call.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - removeAll is not supported by this collection.<DT><B>See Also: </B><DD><A HREF="../../java/util/AbstractCollection.html#remove(java.lang.Object)"><CODE>remove(Object)</CODE></A>, <A HREF="../../java/util/AbstractCollection.html#contains(java.lang.Object)"><CODE>contains(Object)</CODE></A></DL></DD></DL><HR><A NAME="retainAll(java.util.Collection)"><!-- --></A><H3>retainAll</H3><PRE>public boolean <B>retainAll</B>(<A HREF="../../java/util/Collection.html">Collection</A> c)</PRE><DL><DD>Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection. <p> This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's <tt>remove</tt> method.<p> Note that this implementation will throw an <tt>UnsupportedOperationException</tt> if the iterator returned by the <tt>iterator</tt> method does not implement the remove method.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Collection.html#retainAll(java.util.Collection)">retainAll</A></CODE> in interface <CODE><A HREF="../../java/util/Collection.html">Collection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - elements to be retained in this collection.<DT><B>Returns:</B><DD><tt>true</tt> if this 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>retainAll</tt> method is not supported by this collection.<DT><B>See Also: </B><DD><A HREF="../../java/util/AbstractCollection.html#remove(java.lang.Object)"><CODE>remove(Object)</CODE></A>, <A HREF="../../java/util/AbstractCollection.html#contains(java.lang.Object)"><CODE>contains(Object)</CODE></A></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 collection (optional operation). The collection will be empty after this call returns (unless it throws an exception).<p> This implementation iterates over this collection, removing each element using the <tt>Iterator.remove</tt> operation. Most implementations will probably choose to override this method for efficiency.<p> Note that this implementation will throw an <tt>UnsupportedOperationException</tt> if the iterator returned by this collection's <tt>iterator</tt> method does not implement the <tt>remove</tt> method.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Collection.html#clear()">clear</A></CODE> in interface <CODE><A HREF="../../java/util/Collection.html">Collection</A></CODE></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the <tt>remove</tt> method is not supported by this collection.</DL></DD></DL><HR><A NAME="toString()"><!-- --></A><H3>toString</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>toString</B>()</PRE><DL><DD>Returns a string representation of this collection. The string representation consists of a list of the collection's elements in the order they are returned by its iterator, enclosed in square brackets (<tt>"[]"</tt>). Adjacent elements are separated by the characters <tt>", "</tt> (comma and space). Elements are converted to strings as by <tt>String.valueOf(Object)</tt>.<p> This implementation creates an empty string buffer, appends a left square bracket, and iterates over the collection appending the string representation of each element in turn. After appending each element except the last, the string <tt>", "</tt> is appended. Finally a right bracket is appended. A string is obtained from the string buffer, and returned.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#toString()">toString</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>a string representation of this collection.</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/AbstractCollection.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"> PREV CLASS <A HREF="../../java/util/AbstractList.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="AbstractCollection.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | <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 + -