Java Reference
In-Depth Information
HashSet<T>
Package: java.util
Ancestor classes:
Object
|
+--AbstractCollection<T>
|
+--AbstractSet<T>
|
+--HashSet<T>
Implements interfaces: Cloneable, Collection<T>, Serializable, Set<T>
The HashSet<T> class implements all of the methods in the Set<T> interface. The only other
methods in the HashSet<T> class are the constructors. The class T must implement the
equals and hashCode methods.The two constructors that do not involve concepts beyond the
scope of this topic are given as follows.
All the exception classes mentioned are the kind that are not required to be caught in a catch
block or declared in a throws clause.
All the exception classes mentioned are in the package java.lang and so do not require any
import statement.
public HashSet()
Creates a new, empty set.
public HashSet(Collection<? extends T> c )
Creates a new set that contains all the elements of c .
Throws:
NullPointerException if c is null .
public HashSet( int initialCapacity)
Creates a new, empty set with the specifi ed capacity.
Throws:
IllegalArgumentException if initialCapacity is less than zero.
The methods are the same as those described for the Set<T> interface.
Integer
This is a wrapper class for int . See Section 5.1 in Chapter 5 .
 
Search WWH ::




Custom Search