⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 collections.html

📁 j2se5-api-zh,java文档的中文版本
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.5.0_03) on Wed Nov 02 09:50:40 CST 2005 --><META http-equiv="Content-Type" content="text/html; charset=gb2312"><TITLE>Collections (Java 2 Platform SE 5.0)</TITLE><META NAME="keywords" CONTENT="java.util.Collections class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){    parent.document.title="Collections (Java 2 Platform SE 5.0)";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="跳过导航链接"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>概述</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>软件包</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>类</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Collections.html"><FONT CLASS="NavBarFont1"><B>使用</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>树</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>已过时</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>索引</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>帮助</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Standard&nbsp;Ed. 5.0</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="Collection.html" title="java.util 中的接口"><B>上一个类</B></A>&nbsp;&nbsp;<A HREF="Comparator.html" title="java.util 中的接口"><B>下一个类</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../index.html@java_2Futil_2FCollections.html" target="_top"><B>框架</B></A>  &nbsp;&nbsp;<A HREF="Collections.html" target="_top"><B>无框架</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="../../allclasses-noframe.html"><B>所有类</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="../../allclasses-noframe.html"><B>所有类</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  摘要:&nbsp;嵌套&nbsp;|&nbsp;<A HREF="#field_summary">字段</A>&nbsp;|&nbsp;构造方法&nbsp;|&nbsp;<A HREF="#method_summary">方法</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">详细信息:&nbsp;<A HREF="#field_detail">字段</A>&nbsp;|&nbsp;构造方法&nbsp;|&nbsp;<A HREF="#method_detail">方法</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.util</FONT><BR>类 Collections</H2><PRE><A HREF="../lang/Object.html" title="java.lang 中的类">java.lang.Object</A>  <IMG SRC="../../resources/inherit.gif" ALT="继承者 "><B>java.util.Collections</B></PRE><HR><DL><DT><PRE>public class <B>Collections</B><DT>extends <A HREF="../lang/Object.html" title="java.lang 中的类">Object</A></DL></PRE><P>此类完全由在 collection 上进行操作或返回 collection 的静态方法组成。它包含在 collection 上操作的多态算法,即“包装器”,包装器返回由指定 collection 支持的新 collection,以及少数其他内容。<p>如果为此类的方法所提供的 collection 或类对象为 null,则这些方法都会抛出 <tt>NullPointerException</tt>。<p>此类中所含多态算法的文档通常都包括对<i>实现</i> 的简短描述。应该将这类实现视为<i>实现注意事项</i>,而不是将它们视为<i>规范</i> 的一部分。实现者应该可以随意使用其他算法替代,只要遵循规范本身即可。(例如,<tt>sort</tt> 使用的算法不一定是一个合并排序算法,但它必须是<i>稳定的</i>。)<p>如果该 collection 不支持适当的可变基元,比如 <tt>set</tt> 方法,则此类中包含的“破坏性”算法,即可修改其所操作的 collection 的算法,被指定抛出 <tt>UnsupportedOperationException</tt>。如果调用不会对 collection 产生任何影响,那么这些算法可能(但不一定)抛出此异常。例如,在已经排序的、不可修改列表上调用 <tt>sort</tt> 方法可能会(也可能不会)抛出 <tt>UnsupportedOperationException</tt>。<p>此类是 <a href="../../../guide/collections/index.html">Java Collections Framework</a> 的成员。<P><P><DL><DT><B>从以下版本开始:</B></DT>  <DD>1.2</DD><DT><B>另请参见:</B><DD><A HREF="Collection.html" title="java.util 中的接口"><CODE>Collection</CODE></A>, <A HREF="Set.html" title="java.util 中的接口"><CODE>Set</CODE></A>, <A HREF="List.html" title="java.util 中的接口"><CODE>List</CODE></A>, <A HREF="Map.html" title="java.util 中的接口"><CODE>Map</CODE></A></DL><HR><P><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>字段摘要</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="List.html" title="java.util 中的接口">List</A></CODE></FONT></TD><TD><CODE><B><A HREF="Collections.html#EMPTY_LIST">EMPTY_LIST</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;空的列表(不可变的)。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="Map.html" title="java.util 中的接口">Map</A></CODE></FONT></TD><TD><CODE><B><A HREF="Collections.html#EMPTY_MAP">EMPTY_MAP</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;空的映射(不可变的)。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="Set.html" title="java.util 中的接口">Set</A></CODE></FONT></TD><TD><CODE><B><A HREF="Collections.html#EMPTY_SET">EMPTY_SET</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;空的 set(不可变的)。</TD></TR></TABLE>&nbsp;<!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>方法摘要</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""><TR ALIGN="right" VALIGN=""><TD NOWRAP><FONT SIZE="-1"><CODE>&lt;T&gt; boolean</CODE></FONT></TD></TR></TABLE></CODE></FONT></TD><TD><CODE><B><A HREF="Collections.html#addAll(java.util.Collection, T...)">addAll</A></B>(<A HREF="Collection.html" title="java.util 中的接口">Collection</A>&lt;? super T&gt;&nbsp;c,       T...&nbsp;a)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;将所有指定元素添加到指定 collection 中。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""><TR ALIGN="right" VALIGN=""><TD NOWRAP><FONT SIZE="-1"><CODE>&lt;T&gt; int</CODE></FONT></TD></TR></TABLE></CODE></FONT></TD><TD><CODE><B><A HREF="Collections.html#binarySearch(java.util.List, T)">binarySearch</A></B>(<A HREF="List.html" title="java.util 中的接口">List</A>&lt;? extends <A HREF="../lang/Comparable.html" title="java.lang 中的接口">Comparable</A>&lt;? super T&gt;&gt;&nbsp;list,             T&nbsp;key)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;使用二进制搜索算法来搜索指定列表,以获得指定对象。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""><TR ALIGN="right" VALIGN=""><TD NOWRAP><FONT SIZE="-1"><CODE>&lt;T&gt; int</CODE></FONT></TD></TR></TABLE></CODE></FONT></TD><TD><CODE><B><A HREF="Collections.html#binarySearch(java.util.List, T, java.util.Comparator)">binarySearch</A></B>(<A HREF="List.html" title="java.util 中的接口">List</A>&lt;? extends T&gt;&nbsp;list,             T&nbsp;key,             <A HREF="Comparator.html" title="java.util 中的接口">Comparator</A>&lt;? super T&gt;&nbsp;c)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;使用二进制搜索算法来搜索指定列表,以获得指定对象。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""><TR ALIGN="right" VALIGN=""><TD NOWRAP><FONT SIZE="-1"><CODE>&lt;E&gt; <A HREF="Collection.html" title="java.util 中的接口">Collection</A>&lt;E&gt;</CODE></FONT></TD></TR></TABLE></CODE></FONT></TD><TD><CODE><B><A HREF="Collections.html#checkedCollection(java.util.Collection, java.lang.Class)">checkedCollection</A></B>(<A HREF="Collection.html" title="java.util 中的接口">Collection</A>&lt;E&gt;&nbsp;c,                  <A HREF="../lang/Class.html" title="java.lang 中的类">Class</A>&lt;E&gt;&nbsp;type)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回指定 collection 的一个动态类型安全视图。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""><TR ALIGN="right" VALIGN=""><TD NOWRAP><FONT SIZE="-1"><CODE>&lt;E&gt; <A HREF="List.html" title="java.util 中的接口">List</A>&lt;E&gt;</CODE></FONT></TD></TR></TABLE></CODE></FONT></TD><TD><CODE><B><A HREF="Collections.html#checkedList(java.util.List, java.lang.Class)">checkedList</A></B>(<A HREF="List.html" title="java.util 中的接口">List</A>&lt;E&gt;&nbsp;list,            <A HREF="../lang/Class.html" title="java.lang 中的类">Class</A>&lt;E&gt;&nbsp;type)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回指定列表的一个动态类型安全视图。</TD>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -