Java Reference
In-Depth Information
public boolean
addAll(Collection<?
extends
T> collectionToAdd)
(Optional)
Adds all of the elements in
collectionToAdd
to the end of the calling object's list. The
elements are added in the order they are produced by an iterator for
collectionToAdd
.
Throws
:
UnsupportedOperationException
if the
addAll
method is not supported by the calling object.
ClassCastException
if the class of an element in
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 in
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 the
clear
method is not supported by the calling object.
public boolean
remove(Object element)
(Optional)
Removes the fi rst occurrence of
element
from the calling object's list, if it is present. Returns
true
if the calling object contained the
element
; returns
false
otherwise.
Throws:
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).
UnsupportedOperationException
if the
remove
method is not supported by the
calling object.
public boolean
removeAll(Collection<?> collectionToRemove)
(Optional)
Removes all the calling object's elements that are also in
collectionToRemove
. Returns
true
if the calling object was changed; otherwise returns
false
.
Throws:
UnsupportedOperationException
if the
removeAll
method is not supported by the
calling object.
ClassCastException
if the types of one or more elements in the calling object are
incompatible with
collectionToRemove
(optional).
NullPointerException
if the calling object contains one or more
null
elements and
collectionToRemove
does not support
null
elements (optional).
NullPointerException
if
collectionToRemove
is
null
.