Java Reference
In-Depth Information
public boolean add(T newElement)
Adds newElement to the end of the calling vector and increases its size by one. The capacity of the
vector is increased if this is required. Returns true if successful. Normally used as a void method.
METHODS TO REMOVE ELEMENTS
public void clear()
Removes all elements from the calling vector and sets its size to zero.
public T remove( int index)
Deletes the element at the specifi ed index and returns the element deleted. Each element in the
vector with an index greater than or equal to index is decreased to have an index that is one
less than the value it had previously.
Throws:
ArrayIndexOutOfBoundsException if the index is not greater than or equal to 0 and less
than the current size of the vector.
public boolean remove(Object theElement)
Removes the fi rst occurrence of theElement from the calling vector. If theElement is
found in the vector, then each element in the vector with an index greater than or equal to
theElement 's index is decreased to have an index that is 1 less than the value it had previ-
ously. Returns true if theElement was found (and removed). Returns false if theElement
was not found in the calling vector.
SEARCH METHODS
public boolean contains(Object target)
Returns true if target is an element of the calling vector; otherwise returns false .
public int indexOf(Object target)
Returns the index of the fi rst element that is equal to target . Uses the method equals of the
object target to test for equality. Returns − 1 if target is not found.
public int indexOf(Object target, int startIndex)
Returns the index of the fi rst element that is equal to target, but considers only indices that
are greater than or equal to startIndex . Uses the method equals of the object target to
test for equality. Returns − 1 if target is not found.
public boolean isEmpty()
Returns true if the calling vector is empty (that is, has size 0 ); otherwise returns false .
public int lastIndexOf(Object target)
Returns the index of the last element that is equal to target . Uses the method equals of the
object target to test for equality. Returns − 1 if target is not found.
Search WWH ::




Custom Search