Vector.addAll(Collection <? extends E > c) has the following syntax.
public boolean addAll(Collection <? extends E> c)
In the following code shows how to use Vector.addAll(Collection <? extends E > c) method.
//ww w . j a va2s . c om import java.util.Vector; public class Main { public static void main(String[] args) { // create two empty Vectors firstvec and secondvec 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 secondvec with firstvec vector firstvec.addAll(secondvec); // let us print all the elements available in vector firstvec vector System.out.println("Added numbers are :- "); System.out.println(firstvec); } }
The code above generates the following result.