Java Reference
In-Depth Information
Serializable Interface
See Section 10.4 in Chapter 10 .
Set<T> Interface
Package: java.util
Ancestor interfaces: Collection <T>
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.
CONSTRUCTORS
public boolean contains(Object target)
Returns true if the calling object contains at least one instance of target . Uses target.equals
to determine if target is in the calling object.
Throws:
ClassCastException if the type of target is incompatible with the calling object (optional).
NullPointerException if target is null and the calling object does not support null
elements (optional).
public boolean containsAll(Collection<?> collectionOfTargets)
Returns true if the calling object contains all of the elements in collectionOfTargets. For
element in collectionOfTargets , this method uses element.equals to determine if
element is in the calling object. If collectionOfTargets is itself a Set <T> , this is a test to
see if collectionOfTargets is a subset of the calling object.
Throws:
ClassCastException if the types of one or more elements in collectionOfTargets are
incompatible with the calling object (optional).
NullPointerException if collectionOfTargets contains one or more null elements
and the calling object does not support null elements (optional).
NullPointerException if collectionOfTargets is null.
public boolean equals(Object other)
If the argument is a Set <T> , returns true if the calling object and the argument contain exactly the
same elements; otherwise returns false. If the argument is not a Set <T> , false is returned.
public int hashCode()
Returns the hash code value for the calling object. Neither hash codes nor this method are
discussed in this topic. This entry is only here to make the defi nition of the Set <T> interface
complete. You can safely ignore this entry until you go on to study hash codes in a more advanced
book. In the meantime, if you need to implement this method, have it throw an
UnsupportedOperationException.
public boolean isEmpty()
Returns true if the calling object is empty; otherwise returns false.
 
Search WWH ::




Custom Search