Home Java SCJP SCWCD Servlet Submit News Contact Us Site Map


Over 500 magazines for free (including Oracle Magazine)!

Yes all of them are FREE. You can subscribe to ALL of them.
Click here to apply today!

Home > Java > Java Articles

Adding elements to the Vector

1) Adding element to the end of the Vector

boolean add(Object element)

Appends specified element at the end of the Vector.

2) Insert element in the middle of the Vector

void add(int index, Object element)

Inserts specified element into the Vector at given index. This method can throw IndexOutOfBoundsException if index is out of range.

3) Append elements of a Collection to Vector

boolean addAll(Collection c)

Appends all elements of specified Collection to the Vector in order returned by the specified Collection’s Iterator.

4) Insert elements of a Collection to Vector

boolean addAll(int index, Collection c)

Inserts all elements of the specified collection into Vector at given index. This method can throw IndexOutOfBoundsException if index is out of range.


 Replacing the specified element of the Vector

1) Object set(int index, Object element)

Replaces the element at specified index with the object passed as a parameter. Returns the previous element that has been replaced.

2) void setElementAt(Object element, int index)

Replaces the element at specified index with the object passed as a parameter.


<< Java Vector Search Elements

Java Vector Get Remove Elements>>

Home Java SCJP SCWCD Servlet Site map