Vector.addAll(int index, Collection <? extends E > c) has the following syntax.
public boolean addAll(int index, Collection <? extends E> c)
In the following code shows how to use Vector.addAll(int index, Collection <? extends E > c) method.
// w w w. jav a 2s . c om import java.util.Vector; public class Main { public static void main(String[] args) { Vector<Integer> firstvec = new Vector<Integer> (4); Vector<Integer> secondvec = new Vector<Integer> (4); // use add() method to add elements in the secondvec vector secondvec.add(5); secondvec.add(6); secondvec.add(7); secondvec.add(8); // use add() method to add elements in the firstvec vector firstvec.add(1); firstvec.add(2); firstvec.add(3); firstvec.add(4); /** use addAll() method to add elements of the 2nd vector at 1st element position of the first vector */ firstvec.addAll(1,secondvec); System.out.println(firstvec); } }
The code above generates the following result.