Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Add elements to Java Vector, Replace elements from Java Vector, Insert elements in Java Vector

Add Insert 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 >>
Your rating: None Average: 3 (1 vote)
Share this

Post new comment