java.util.Set翻译

779 篇文章 0 订阅
<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

  java/util/Set.html#skip-navbar_top" />overviewjava/util/package-summary.html" />packageclassjava/util/class-use/Set.html" />usejava/util/package-tree.html" />treedeprecatedindexhelpjavaTM2PlatformStd.Ed. v1.4.2 java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/randomaccess.html" />PREV CLASS java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/sortedmap.html" />NEXT CLASSFRAMES java/util/Set.html" target="_top" />NO FRAMES

 

  All Classes SUMMARY:NESTED|FIELD|CONSTR|java/util/Set.html#method_summary" />METHODDETAIL:FIELD|CONSTR|java/util/Set.html#method_detail" />METHODjava.util Interface SetAll Superinterfaces: java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />Collection All Known Subinterfaces: java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/sortedSet.html" />SortedSet All Known Implementing Classes: java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/abstractSet.html" />AbstractSet, java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/hashSet.html" />HashSet, java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/linkedhashSet.html" />LinkedHashSet, java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/treeSet.html" />TreeSet public interface Set extends java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionA collection that contains no duplicate elements. More formally, Sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element. As implied by its name, this interface models the mathematical Set abstraction. 不包含重复元素的集合。更正式地讲,Set中不存在那样的一对元素,e1和e2,使得e1.equals(e2),至多也只能有一个null元素。和它名称暗示的一样,接口模拟了数学中的Set概念。 The Set interface places additional stipulations, beyond those inherited from the Collection interface, on the contracts of all constructors and on the contracts of the add, equals and hashCode methods. Declarations for other inherited methods are also included here for convenience. (The specifications accompanying these declarations have been tailored to the Set interface, but they do not contain any additional stipulations.) Set接口除了继承自Collection接口,遵守所有构造函数、add、equals和hashCode方法的约定之外, 还有一些额外约定。其他继承方法的声明为了简便起见,也包括在此。 (和这些声明相关的规定在Set接口中已有修正,但是它们不包括任何额外的约定。) The additional stipulation on constructors is, not surprisingly, that all constructors must create a Set that contains no duplicate elements (as defined above). 构造函数的额外约定并不新鲜,它要求所有构造函数必须创建一个不包含重复元素的Set(根据以上定义)。 Note: Great care must be exercised if mutable objects are used as Set elements. The behavior of a Set is not specified if the value of an object is changed in a manner that affects equals comparisons while the object is an element in the Set. A special case of this prohibition is that it is not permissible for a Set to contain itself as an element. 注意:如果Set元素为可变对象,应该引起足够注意。如果某个对象的值以某种方法改变,而该对象是Set中的一个元素,影响了equals比较,那么Set的行为无法确定。 Some Set implementations have restrictions on the elements that they may contain. For example, some implementations prohibit null elements, and some have restrictions on the types of their elements. Attempting to add an ineligible element throws an unchecked exception, typically NullPointerException or ClassCastException. Attempting to query the presence of an ineligible element may throw an exception, or it may simply return false; some implementations will exhibit the former behavior and some will exhibit the latter. More generally, attempting an operation on an ineligible element whose completion would not result in the insertion of an ineligible element into the Set may throw an exception or it may succeed, at the option of the implementation. Such exceptions are marked as "optional" in the specification for this interface. 某些Set的实现对于它所包含的元素有限制。例如,某些实现禁止null元素,某些元素的类型受限制。试图加入一个不适当的元素会抛出未检查异常,通常为NullPointerException或ClassCastException。试图查询一个不适当的元素是否存在也可能抛出异常,或者简单返回false。某些实现显示前者,某些显示后者。更一般而言,试图对一个不适当的元素进行操作会造成不适当元素向Set的插入,根据option实现的不同,可能抛出异常,也可能成功。那些异常在该接口的规范中标记为“optional(可选)”。 This interface is a member of the java Collections Framework. 该接口是java集合框架成员之一。 Since: 1.2 See Also: java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />Collection, java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/list.html" />List, java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/sortedSet.html" />SortedSet, java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/hashSet.html" />HashSet, java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/treeSet.html" />TreeSet, java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/abstractSet.html" />AbstractSet, java/util/collections.html#singleton(java.lang.object)" />Collections.singleton(java.lang.Object), java/util/collections.html#empty_Set" />Collections.EMPTY_Setmethod summarybooleanjava/util/Set.html#add(java.lang.object)" />add(java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />objecto) adds the specified element to this Set if it is not already present (optional operation). 如果Set中不存在指定元素,则向Set加入(可选操作)。booleanjava/util/Set.html#addall(java.util.collection)" />addall(java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />collectionc) adds all of the elements in the specified collection to this Set if they're not already present (optional operation). 如果Set中中不存在指定集合的元素,则向Set中加入所有元素(可选操作)。voidjava/util/Set.html#clear()" />clear() removes all of the elements from this Set (optional operation). 从Set中删除所有元素(可选操作)。booleanjava/util/Set.html#contains(java.lang.object)" />contains(java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />objecto) returns true if this Set contains the specified element. 如果Set包含指定元素,返回true。booleanjava/util/Set.html#containsall(java.util.collection)" />containsall(java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />collectionc) returns true if this Set contains all of the elements of the specified collection. 如果Set包含指定集合的所有元素,返回true。booleanjava/util/Set.html#equals(java.lang.object)" />equals(java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />objecto) compares the specified object with this Set for equality. 将指定对象和当前Set就相等性进行比较。intjava/util/Set.html#hashcode()" />hashcode() returns the hash code value for this Set. 返回Set的哈希码值。booleanjava/util/Set.html#isempty()" />isempty() returns true if this Set contains no elements. 如果Set中不含元素,返回true。java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/iterator.html" />iteratorjava/util/Set.html#iterator()" />iterator() returns an iterator over the elements in this Set. 返回Set中元素的迭代器。booleanjava/util/Set.html#remove(java.lang.object)" />remove(java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />objecto) removes the specified element from this Set if it is present (optional operation). 如果Set中存在指定元素,则从Set中删除(可选操作)。booleanjava/util/Set.html#removeall(java.util.collection)" />removeall(java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />collectionc) removes from this Set all of its elements that are contained in the specified collection (optional operation). 如果Set包含指定集合,则从Set中删除指定集合的所有元素(可选操作)。booleanjava/util/Set.html#retainall(java.util.collection)" />retainall(java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />collectionc) retains only the elements in this Set that are contained in the specified collection (optional operation). 只保留Set中所含的指定集合的元素(可选操作)。intjava/util/Set.html#size()" />size() returns the number of elements in this Set (its cardinality). 返回Set中元素的数目。java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />object[]java/util/Set.html#toarray()" />toarray() returns an array containing all of the elements in this Set. 返回包含Set中所有元素的数组。java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />object[]java/util/Set.html#toarray(java.lang.object[])" />toarray(java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />object[]a) returns an array containing all of the elements in this Set; the runtime type of the returned array is that of the specified array. 返回包含Set中所有元素的数组,返回数组的运行时类型是指定数组的运行时类型。 method detailsizepublic int size()Returns the number of elements in this Set (its cardinality). If this Set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE. 返回Set中元素的数目。如果Set包含的元素数大于Integer.MAX_VALUE,返回Integer.MAX_VALUE。 Specified by: java/util/collection.html#size()" />size in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionReturns: the number of elements in this Set (its cardinality). Set中元素的数目。isEmptypublic boolean isEmpty()Returns true if this Set contains no elements. 如果Set中不含元素,返回true。 Specified by: java/util/collection.html#isempty()" />isEmpty in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionReturns: true if this Set contains no elements. 如果Set中不含元素,返回true。java.lang.object)" />containspublic boolean contains(java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />Objecto)Returns true if this Set contains the specified element. More formally, returns true if and only if this Set contains an element e such that (o==null ? e==null : o.equals(e)). 如果Set包含指定元素,返回true。更正式地讲,只有当Set包含元素e,使得(o==null ? e==null : o.equals(e)),才返回true。 Specified by: java/util/collection.html#contains(java.lang.object)" />contains in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionParameters: o - element whose presence in this Set is to be tested. 元素,用来测试是否存在于Set中。 Returns: true if this Set contains the specified element. 如果Set包含指定元素,返回true。 Throws: java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/classcastexception.html" />ClassCastException - if the type of the specified element is incompatible with this Set (optional). 如果指定元素的类型和Set中的不匹配,则抛出(可选)。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/nullpointerexception.html" />NullPointerException - if the specified element is null and this Set does not support null elements (optional). 如果指定元素为null,而Set不支持null元素,则抛出(可选)。iteratorpublic java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/iterator.html" />Iterator iterator()Returns an iterator over the elements in this Set. The elements are returned in no particular order (unless this Set is an instance of some class that provides a guarantee). 返回Set中元素的迭代器。元素返回没有特定的顺序,除非Set是提高了该保证的某些类的实例。 Specified by: java/util/collection.html#iterator()" />iterator in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionReturns: an iterator over the elements in this Set. Set中元素的迭代器。toArraypublic java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />Object[] toArray()Returns an array containing all of the elements in this Set. Obeys the general contract of the Collection.toArray method. 返回包含Set中所有元素的数组。遵守Collection.toArray方法的一般约定。 Specified by: java/util/collection.html#toarray()" />toArray in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionReturns: an array containing all of the elements in this Set. 包含Set中所有元素的数组。java.lang.object[])" />toArraypublic java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />Object[] toArray(java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />Object[]a)Returns an array containing all of the elements in this Set; the runtime type of the returned array is that of the specified array. Obeys the general contract of the Collection.toArray(Object[]) method. 返回包含Set中所有元素的数组,返回数组的运行时类型是指定数组的运行时类型。 Specified by: java/util/collection.html#toarray(java.lang.object[])" />toArray in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionParameters: a - the array into which the elements of this Set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose. Set中元素要被存储的数组,如果它足够大;否则,为此构建一个运行时类型相同的新的数组。 Returns: an array containing the elements of this Set. 包含Set中所有元素的数组。 Throws: java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/arraystoreexception.html" />ArrayStoreException - the runtime type of a is not a supertype of the runtime type of every element in this Set. 如果a的运行时类型不是Set中每个元素运行时类型的父一级类型时抛出。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/nullpointerexception.html" />NullPointerException - if the specified array is null. 如果指定数组为null时抛出。java.lang.object)" />addpublic boolean add(java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />Objecto)Adds the specified element to this Set if it is not already present (optional operation). More formally, adds the specified element, o, to this Set if this Set contains no element e such that (o==null ? e==null : o.equals(e)). If this Set already contains the specified element, the call leaves this Set unchanged and returns false. In combination with the restriction on constructors, this ensures that Sets never contain duplicate elements. 如果Set中不存在指定元素,则向Set加入(可选操作)。更正式地讲,如果Set不含这样的 元素e,使得(o==null ? e==null : o.equals(e)),那么向Set加入指定元素o。 如果Set已经包含了指定元素,调用不改变Set,返回false。 构造函数中的限制,将确保Set不会包含重复元素。 The stipulation above does not imply that Sets must accept all elements; Sets may refuse to add any particular element, including null, and throwing an exception, as described in the specification for Collection.add. Individual Set implementations should clearly document any restrictions on the the elements that they may contain. 以上的规定并不意味着Set可以接受所有元素,Set可能拒绝加入某个特定元素,包括 null,抛出异常,和规范中Collection.add的描述一样。特殊的Set实现应当在文档中 明确Set可以包含元素的限制。 Specified by: java/util/collection.html#add(java.lang.object)" />add in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionParameters: o - element to be added to this Set. 要加入Set的元素。 Returns: true if this Set did not already contain the specified element. 如果Set中还未包含指定元素,返回true。 Throws: java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/unsupportedoperationexception.html" />UnsupportedOperationException - if the add method is not supported by this Set. 如果当前Set不支持add方法时抛出。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/classcastexception.html" />ClassCastException - if the class of the specified element prevents it from being added to this Set. 如果指定集合的某些元素类型阻止其加入Set时抛出。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/nullpointerexception.html" />NullPointerException - if the specified element is null and this Set does not support null elements. 如果指定元素为null而Set不支持null元素时抛出。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/illegalargumentexception.html" />IllegalArgumentException - if some aspect of the specified element prevents it from being added to this Set. 如果指定元素的某些方面不允许它加入当前Set则抛出。java.lang.object)" />removepublic boolean remove(java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />Objecto)Removes the specified element from this Set if it is present (optional operation). More formally, removes an element e such that (o==null ? e==null : o.equals(e)), if the Set contains such an element. Returns true if the Set contained the specified element (or equivalently, if the Set changed as a result of the call). (The Set will not contain the specified element once the call returns.) 如果Set中存在指定元素,则从Set中删除(可选操作)。更正式地讲,如果Set中含有那样一个元素e, 使得(o==null ? e==null : o.equals(e)),那么删除元素e。如果Set包含指定元素,返回true( 也可以说,调用的结果使得Set发生改变)。一旦Set不含指定元素,调用返回。 Specified by: java/util/collection.html#remove(java.lang.object)" />remove in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionParameters: o - object to be removed from this Set, if present. 要从Set中删除的对象(若有)。 Returns: true if the Set contained the specified element. 如果Set中存在指定元素,返回true。 Throws: java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/classcastexception.html" />ClassCastException - if the type of the specified element is incompatible with this Set (optional). 如果指定元素的类型和当前Set中的不匹配,则抛出(可选)。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/nullpointerexception.html" />NullPointerException - if the specified element is null and this Set does not support null elements (optional). 如果指定元素为null而Set不支持null元素时抛出(可选)。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/unsupportedoperationexception.html" />UnsupportedOperationException - if the remove method is not supported by this Set. 如果当前Set不支持remove方法则抛出。java.util.collection)" />containsAllpublic boolean containsAll(java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />Collectionc)Returns true if this Set contains all of the elements of the specified collection. If the specified collection is also a Set, this method returns true if it is a subSet of this Set. 如果Set包含指定集合的所有元素,返回true。如果指定集合也是一个Set,只有是当前Set的子集时,方法返回true。 Specified by: java/util/collection.html#containsall(java.util.collection)" />containsAll in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionParameters: c - collection to be checked for containment in this Set. 检查Set包容性的集合。 Returns: true if this Set contains all of the elements of the specified collection. 如果Set包含指定集合的所有元素,返回true。 Throws: java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/classcastexception.html" />ClassCastException - if the types of one or more elements in the specified collection are incompatible with this Set (optional). 如果指定集合的一个或多个元素的类型和Set中的不匹配,则抛出(可选)。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/nullpointerexception.html" />NullPointerException - if the specified collection contains one or more null elements and this Set does not support null elements (optional). 如果指定集合中包含一个或多个null元素,而Set不支持null元素则抛出(可选)。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/nullpointerexception.html" />NullPointerException - if the specified collection is null. 如果指定集合为null抛出。 See Also: java/util/Set.html#contains(java.lang.object)" />contains(Object)java.util.collection)" />addAllpublic boolean addAll(java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />Collectionc)Adds all of the elements in the specified collection to this Set if they're not already present (optional operation). If the specified collection is also a Set, the addAll operation effectively modifies this Set so that its value is the union of the two Sets. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. 如果Set中中不存在指定集合的元素,则向Set中加入所有元素(可选操作)。 如果指定集合也是一个Set,那么addAll操作修改Set的效果是使它的值为两个Set的并集。 如果操作进行中指定集合被修改,那么该操作的行为无法确定。 Specified by: java/util/collection.html#addall(java.util.collection)" />addAll in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionParameters: c - collection whose elements are to be added to this Set. 要将其元素加入Set的集合。 Returns: true if this Set changed as a result of the call. 如果调用的结果改变了Set,返回true。 Throws: java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/unsupportedoperationexception.html" />UnsupportedOperationException - if the addAll method is not supported by this Set. 如果当前Set不支持addAll方法抛出。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/classcastexception.html" />ClassCastException - if the class of some element of the specified collection prevents it from being added to this Set. 如果指定集合的某些元素类型阻止其加入Set时抛出。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/nullpointerexception.html" />NullPointerException - if the specified collection contains one or more null elements and this Set does not support null elements, or if the specified collection is null. 如果指定集合包含一个或多个null元素而当前Set不支持null元素,或者指定集合为null抛出。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/illegalargumentexception.html" />IllegalArgumentException - if some aspect of some element of the specified collection prevents it from being added to this Set. 如果指定集合的某些元素的某些方面不允许它加入当前Set则抛出。 See Also: java/util/Set.html#add(java.lang.object)" />add(Object)java.util.collection)" />retainAllpublic boolean retainAll(java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />Collectionc)Retains only the elements in this Set that are contained in the specified collection (optional operation). In other words, removes from this Set all of its elements that are not contained in the specified collection. If the specified collection is also a Set, this operation effectively modifies this Set so that its value is the intersection of the two Sets. 只保留Set中所含的指定集合的元素(可选操作)。换言之,从Set中删除所有指定集合不包含的元素。 如果指定集合也是一个Set,那么该操作修改Set的效果是使它的值为两个Set的交集。 Specified by: java/util/collection.html#retainall(java.util.collection)" />retainAll in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionParameters: c - collection that defines which elements this Set will retain. 定义Set将保留元素的集合。 Returns: true if this collection changed as a result of the call. 如果调用的结果改变了集合,返回true。 Throws: java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/unsupportedoperationexception.html" />UnsupportedOperationException - if the retainAll method is not supported by this Collection. 如果当前Collection不支持retainAll方法时抛出。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/classcastexception.html" />ClassCastException - if the types of one or more elements in this Set are incompatible with the specified collection (optional). 如果当前Set的一个或多个元素的类型和指定集合中的不匹配,则抛出(可选)。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/nullpointerexception.html" />NullPointerException - if this Set contains a null element and the specified collection does not support null elements (optional). 如果当前Set包含一个或多个null元素,而指定集合不支持null元素则抛出(可选)。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/nullpointerexception.html" />NullPointerException - if the specified collection is null. 如果指定集合为null抛出。 See Also: java/util/Set.html#remove(java.lang.object)" />remove(Object)java.util.collection)" />removeAllpublic boolean removeAll(java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />Collectionc)Removes from this Set all of its elements that are contained in the specified collection (optional operation). If the specified collection is also a Set, this operation effectively modifies this Set so that its value is the asymmetric Set difference of the two Sets. 如果Set包含指定集合,则从Set中删除指定集合的所有元素(可选操作)。 如果指定集合也是一个Set,那么该操作修改Set的效果是使它的值为两个Set的(不对称)差集。 Specified by: java/util/collection.html#removeall(java.util.collection)" />removeAll in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionParameters: c - collection that defines which elements will be removed from this Set. 集合,定义为从Set中删除它的元素。 Returns: true if this Set changed as a result of the call. 如果调用的结果改变了Set,返回true。 Throws: java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/unsupportedoperationexception.html" />UnsupportedOperationException - if the removeAll method is not supported by this Collection. 如果当前Collection不支持removeAll方法时抛出。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/classcastexception.html" />ClassCastException - if the types of one or more elements in this Set are incompatible with the specified collection (optional). 如果当前Set的一个或多个元素的类型和指定集合中的不匹配,则抛出(可选)。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/nullpointerexception.html" />NullPointerException - if this Set contains a null element and the specified collection does not support null elements (optional). 如果当前Set包含一个或多个null元素,而指定集合不支持null元素则抛出(可选)。 java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/nullpointerexception.html" />NullPointerException - if the specified collection is null. 如果指定集合为null时抛出。 See Also: java/util/Set.html#remove(java.lang.object)" />remove(Object)clearpublic void clear()Removes all of the elements from this Set (optional operation). This Set will be empty after this call returns (unless it throws an exception). 从Set中删除所有元素(可选操作)。在调用返回后Set将为空(除非抛出异常)。 Specified by: java/util/collection.html#clear()" />clear in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />CollectionThrows: java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/unsupportedoperationexception.html" />UnsupportedOperationException - if the clear method is not supported by this Set. 如果当前Set不支持clear方法,则抛出。java.lang.object)" />equalspublic boolean equals(java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />Objecto)Compares the specified object with this Set for equality. Returns true if the specified object is also a Set, the two Sets have the same size, and every member of the specified Set is contained in this Set (or equivalently, every member of this Set is contained in the specified Set). This definition ensures that the equals method works properly across different implementations of the Set interface. 将指定对象和当前Set就相等性进行比较。如果指定对象也是一个Set,两个Set有着相同大小,指定Set的每一个成员在当前 Set中(也可以说当前Set的每一个成员包含在指定Set中)。该定义可以 保证对于Set接口的不同实现,equals方法都能正常工作。 Specified by: java/util/collection.html#equals(java.lang.object)" />equals in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />Collection Overrides: java/lang/object.html#equals(java.lang.object)" />equals in class java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />ObjectParameters: o - Object to be compared for equality with this Set. 同当前Set比较相等性的Object。 Returns: true if the specified Object is equal to this Set. 如果指定对象和当前Set相等,返回true。 See Also: java/lang/object.html#hashcode()" />Object.hashCode(), java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/hashtable.html" />HashtablehashCodepublic int hashCode()Returns the hash code value for this Set. The hash code of a Set is defined to be the sum of the hash codes of the elements in the Set, where the hashcode of a null element is defined to be zero. This ensures that s1.equals(s2) implies that s1.hashCode()==s2.hashCode() for any two Sets s1 and s2, as required by the general contract of the Object.hashCode method. 返回Set的哈希码值。Set的哈希码被定义为Set中元素的哈希码之和,这里null元素的哈希码被定义为0。 这将保证对于两个Set s1和s2,s1.equals(s2)意味着s1.hashCode()==s2.hashCode(),遵循 Object.hashCode方法的一般约定。 Specified by: java/util/collection.html#hashcode()" />hashCode in interface java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/collection.html" />Collection Overrides: java/lang/object.html#hashcode()" />hashCode in class java.lang" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/lang/object.html" />ObjectReturns: the hash code value for this Set. Set的哈希码值。 See Also: java/lang/object.html#hashcode()" />Object.hashCode(), java/lang/object.html#equals(java.lang.object)" />Object.equals(Object), java/util/Set.html#equals(java.lang.object)" />equals(Object)java/util/Set.html#skip-navbar_bottom" />overviewjava/util/package-summary.html" />packageclassjava/util/class-use/Set.html" />usejava/util/package-tree.html" />treedeprecatedindexhelpjavaTM2PlatformStd.Ed. v1.4.2 java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/randomaccess.html" />PREV CLASS java.util" href="file:///f:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/java/util/sortedmap.html" />NEXT CLASSFRAMES java/util/Set.html" target="_top" />NO FRAMES

 

  All Classes SUMMARY:NESTED|FIELD|CONSTR|java/util/Set.html#method_summary" />METHODDETAIL:FIELD|CONSTR|java/util/Set.html#method_detail" />METHODjava.sun.com/cgi-bin/bugreport.cgi" />Submit a bug or featureFor further API reference and developer documentation, see java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the java.sun.com/docs/redist.html" />documentation redistribution policy.

<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值