Java Reference
In-Depth Information
public boolean
add(T element)
(Optional)
Ensures that the calling object contains the specifi ed
element
. Returns
true
if the calling
object changed as a result of the call. Returns
false
if the calling object does not permit
duplicates and already contains
element
; also returns
false
if the calling object does not
change for any other reason.
Throws:
UnsupportedOperationException
if this method is not supported by the class that
implements this interface.
ClassCastException
if the class of
element
prevents it from being added to the calling object.
NullPointerException
if element is
null
and the calling object does not support
null
elements.
IllegalArgumentException
if some other aspect of
element
prevents it from
being added to the calling object.
public boolean
addAll(Collection<?
extends
T> collectionToAdd)
(
Optional)
Ensures that the calling object contains all the elements in
collectionToAdd.
Returns
true
if the calling object changed as a result of the call; returns
false
otherwise. If the calling object
changes during this operation, its behavior is unspecifi ed; in particular, it behavior is unspecifi ed
if
collectionToAdd
is the calling object.
Throws:
UnsupportedOperationException
if this method is not supported by the class that
implements this interface.
ClassCastException
if the class of an element of
collectionToAdd
prevents it from being
added to the calling object.
NullPointerException
if
collectionToAdd
contains one or more
null
elements and the
calling object does not support
null
elements, or if
collectionToAdd
is
null
.
IllegalArgumentException
if some aspect of an element of
collectionToAdd
prevents
it from being added to the calling object.
public void
clear()
(Optional)
Removes all the elements from the calling object.
Throws:
UnsupportedOperationException
if this method is not supported by the class that
implements this interface.
public boolean
remove(Object element)
(Optional)
Removes a single instance of
element
from the calling object, if it is present. Returns
true
if
the calling object contained
element
; returns
false
otherwise.
Throws:
UnsupportedOperationException
if this method is not supported by the class that
implements this interface.
ClassCastException
if the type of
element
is incompatible with the calling object (optional).
NullPointerException
if
element
is
null
and the calling object does not support
null
elements (optional).