Java Reference
In-Depth Information
Returns an iterator that steps through the elements of this
collection.
public Object[]
toArray()
Returns a new array that contains all the elements of this col-
lection.
public <T> T[]
toArray(T[] dest)
Returns an array that contains all the elements of this collec-
tion. If the elements will fit in
dest
, then they are placed in
dest
and it is
dest
that is returned. If
dest
has more elements
than this collection, the first element in
dest
that follows the
contents of the collection is set to
null
to mark the end of the
collection. If the elements do not fit in
dest
, a new, larger ar-
ray is created of the same type as
dest
, filled in, and returned.
If the type of
dest
is not compatible all the elements in the
collection, an
ArrayStoreException
is thrown.
public boolean
add(E elem)
Makes sure that this collection contains the object
elem
, re-
turning
true
if this required changing the collection. If this col-
lection allows duplicates,
add
will always return
true
. If duplic-
ates are not allowed and an equivalent element is already in
the collection,
add
will return
false
. (Optional)
public boolean
remove(Object elem)
Removes a single instance of
elem
from the collection, return-
ing
true
if this required changing the collection (that is, if the
element existed in this collection). If
elem
is
null
, returns
TRue
if there was a
null
element in the collection. (Optional)