php    php100   android
當前位置:首頁 » Java.util包 »

Java.util.HashSet類

評論  編輯

The java.util.HashSet class implements the Set interface, backed by a hash table.Following are the important points about HashSet:

  • This class makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time.

  • This class permits the null element.

類聲明

以下是聲明java.util.HashSet class:

public class HashSet<E>
   extends AbstractSet<E>
      implements Set<E>, Cloneable, Serializable

Parameters

Following is the parameter for java.util.HashSet class:

  • E -- This is the type of elements maintained by this set.

類構造方法

S.N.構造方法 & 詳細描述
1HashSet()
This constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).
2HashSet(Collection<? extends E> c)
This constructs a new set containing the elements in the specified collection.
3HashSet(int initialCapacity)
This constructs a new, empty set; the backing HashMap instance has the specified initial capacity and default load factor (0.75).
4HashSet(int initialCapacity, float loadFactor)
This constructs a new, empty set; the backing HashMap instance has the specified initial capacity and the specified load factor.

類方法

S.N.方法 & 描述
1 boolean add(E e)
This method adds the specified element to this set if it is not already present.
2 void clear()
This method removes all of the elements from this set.
3 Object clone()
This method returns a shallow copy of this HashSet instance, the elements themselves are not cloned.
4 boolean contains(Object o)
This method returns true if this set contains the specified element.
5 boolean isEmpty()
This method returns true if this set contains no elements.
6 Iterator<E> iterator()
This method returns an iterator over the elements in this set.
7 boolean remove(Object o)
This method removes the specified element from this set if it is present.
8 int size()
This method returns returns the number of elements in this set(its cardinality).

方法繼承

此類從以下類繼承了上麵列出的方法

  • java.util.AbstractSet

  • java.util.AbstractCollection

  • java.util.Object

  • java.util.Set


貢獻/合作者

正在開放中...
 

評論(條)

  • 還冇有評論!