📄 collection.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:36:42 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Interface Collection</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_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/Collection.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/Comparator.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="Collection.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.util</FONT><BR>Interface Collection</H2><DL><DT><B>All Known Subinterfaces:</B> <DD><A HREF="../../java/beans/beancontext/BeanContext.html">BeanContext</A>, <A HREF="../../java/beans/beancontext/BeanContextServices.html">BeanContextServices</A>, <A HREF="../../java/util/List.html">List</A>, <A HREF="../../java/util/Set.html">Set</A>, <A HREF="../../java/util/SortedSet.html">SortedSet</A></DD></DL><DL><DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></DD></DL><HR><DL><DT>public interface <B>Collection</B></DL><P>The root interface in the <i>collection hierarchy</i>. A collection represents a group of objects, known as its <i>elements</i>. Some collections allow duplicate elements and others do not. Some are ordered and others unordered. The SDK does not provide any <i>direct</i> implementations of this interface: it provides implementations of more specific subinterfaces like <tt>Set</tt> and <tt>List</tt>. This interface is typically used to pass collections around and manipulate them where maximum generality is desired.<p> <i>Bags</i> or <i>multisets</i> (unordered collections that may contain duplicate elements) should implement this interface directly.<p> All general-purpose <tt>Collection</tt> implementation classes (which typically implement <tt>Collection</tt> indirectly through one of its subinterfaces) should provide two "standard" constructors: a void (no arguments) constructor, which creates an empty collection, and a constructor with a single argument of type <tt>Collection</tt>, which creates a new collection with the same elements as its argument. In effect, the latter constructor allows the user to copy any collection, producing an equivalent collection of the desired implementation type. There is no way to enforce this convention (as interfaces cannot contain constructors) but all of the general-purpose <tt>Collection</tt> implementations in the SDK comply.<p><P><DL><DT><B>Since: </B><DD>1.2</DD><DT><B>See Also: </B><DD><A HREF="../../java/util/Set.html"><CODE>Set</CODE></A>, <A HREF="../../java/util/List.html"><CODE>List</CODE></A>, <A HREF="../../java/util/Map.html"><CODE>Map</CODE></A>, <A HREF="../../java/util/SortedSet.html"><CODE>SortedSet</CODE></A>, <A HREF="../../java/util/SortedMap.html"><CODE>SortedMap</CODE></A>, <A HREF="../../java/util/HashSet.html"><CODE>HashSet</CODE></A>, <A HREF="../../java/util/TreeSet.html"><CODE>TreeSet</CODE></A>, <A HREF="../../java/util/ArrayList.html"><CODE>ArrayList</CODE></A>, <A HREF="../../java/util/LinkedList.html"><CODE>LinkedList</CODE></A>, <A HREF="../../java/util/Vector.html"><CODE>Vector</CODE></A>, <A HREF="../../java/util/Collections.html"><CODE>Collections</CODE></A>, <A HREF="../../java/util/Arrays.html"><CODE>Arrays</CODE></A>, <A HREF="../../java/util/AbstractCollection.html"><CODE>AbstractCollection</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></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/Collection.html#add(java.lang.Object)">add</A></B>(<A HREF="../../java/lang/Object.html">Object</A> o)</CODE><BR> Ensures that this collection contains the specified element (optional operation).</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/Collection.html#addAll(java.util.Collection)">addAll</A></B>(<A HREF="../../java/util/Collection.html">Collection</A> c)</CODE><BR> Adds all of the elements in the specified collection to this collection (optional operation).</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/Collection.html#clear()">clear</A></B>()</CODE><BR> Removes all of the elements from this collection (optional operation).</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/Collection.html#contains(java.lang.Object)">contains</A></B>(<A HREF="../../java/lang/Object.html">Object</A> o)</CODE><BR> Returns <tt>true</tt> if this collection contains the specified element.</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/Collection.html#containsAll(java.util.Collection)">containsAll</A></B>(<A HREF="../../java/util/Collection.html">Collection</A> c)</CODE><BR> Returns <tt>true</tt> if this collection contains all of the elements in the specified collection.</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/Collection.html#equals(java.lang.Object)">equals</A></B>(<A HREF="../../java/lang/Object.html">Object</A> o)</CODE><BR> Compares the specified object with this collection for equality.</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/Collection.html#hashCode()">hashCode</A></B>()</CODE><BR> Returns the hash code value for this collection.</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/Collection.html#isEmpty()">isEmpty</A></B>()</CODE><BR> Returns <tt>true</tt> if this collection contains no elements.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/util/Iterator.html">Iterator</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collection.html#iterator()">iterator</A></B>()</CODE><BR> Returns an iterator over the elements in this collection.</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/Collection.html#remove(java.lang.Object)">remove</A></B>(<A HREF="../../java/lang/Object.html">Object</A> o)</CODE><BR> Removes a single instance of the specified element from this
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -