Java Reference
In-Depth Information
public boolean retainAll(Collection<?> saveElements) (Optional)
Retains only the elements in the calling object that are also in the collection saveElements . In other
words, removes from the calling object all of its elements that are not contained in the collection
saveElements . Returns true if the calling object was changed; otherwise returns false .
Throws:
UnsupportedOperationException if the retainAll method is not supported by the calling
object.
ClassCastException if the types of one or more elements in the calling object are
incompatible with saveElements (optional).
NullPointerException if the calling object contains one or more null elements and
saveElements does not support null elements (optional).
NullPointerException if the collection saveElements is null .
NEW METHOD HEADINGS
The following methods are in the List<T> interface but were not in the Collection<T>
interface. Those that are optional are noted.
public void add( int index, T newElement) (Optional)
Inserts newElement in the calling object's list at location index . The old elements at location
index and higher are moved to higher indices.
Throws:
IndexOutOfBoundsException if the index is not in the range:
0 <= index <= size().
UnsupportedOperationException if this add method is not supported by the calling object.
ClassCastException if the class of newElement prevents it from being added to
the calling object.
NullPointerException if newElement is null and the calling object does not support
null elements.
IllegalArgumentException if some aspect of newElement prevents it from being added to
the calling object.
public boolean addAll( int index,
Collection<? extends T> collectionToAdd) (Optional)
Inserts all of the elements in collectionToAdd to the calling object's list starting at location
index . The old elements at location index and higher are moved to higher indices. The
elements are added in the order they are produced by an iterator for collectionToAdd .
Returns true if successful; otherwise returns false .
Throws:
IndexOutOfBoundsException if the index is not in the range:
0 <= index <= size() .
UnsupportedOperationException if the addAll method is not supported by the
calling object.
ClassCastException if the class of one of the elements 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 one of the elements of collectionToAdd
prevents it from being added to the calling object.
Search WWH ::




Custom Search