Java Reference
In-Depth Information
public T firstElement()
Returns the fi rst element of the calling vector.
Throws:
NoSuchElementException if the vector is empty.
public T lastElement()
Returns the last element of the calling vector.
Throws:
NoSuchElementException if the vector is empty.
ITERATORS
public Iterator <T> iterator()
Returns an iterator for the calling vector. (Iterators are discussed in Chapter 16.)
ListIterator <T> listIterator()
Returns a list iterator for the calling vector. (Iterators are discussed in Chapter 16.)
ListIterator <T> listIterator( int index)
Returns a list iterator for the calling vector starting at index . The fi rst element to be returned by
the iterator is the one at index. (Iterators are discussed in Chapter 16.)
CONVERTING TO AN ARRAY
public Object[] toArray()
Returns an array containing all of the elements in the vector. The elements of the array are indexed
the same as in the vector.
public <E> E[] toArray(E[] a)
Note that the type parameter E is not the same as T. So, E can be any reference type; it need
not be the type T in Collection <T> . For example, E might be an ancestor type of T.
Returns an array containing all of the elements in the calling object. The elements in the returned
array are in the same order as in the calling object. The argument a is used primarily to specify the
type of the array returned. The exact details are described in the table for the Collection <T>.
Throws:
ArrayStoreException if the base type of a is not an ancestor class of all the elements in
the vector.
NullPointerException if a is null .
MEMORY MANAGEMENT
public int capacity()
Returns the current capacity of the calling vector.
Search WWH ::




Custom Search