Once an element has been placed in a vector, you can
retrieve that element
using the elementAt
method with an integer argument. For example,
the following expression retrieves the element identified by an integer
variable, counter
, from the vector, v
:
v.elementAt(counter)
Similarly, you can
replace an element using the setElementAt
method.
For example, the following expression replaces the element identified by
the value of an integer variable, counter
, by the instance assigned
to the instance variable, m
:
v.setElementAt(m, counter)
Thus, elementAt
and setElementAt
allow you to use a vector as
though it were an array.