The addAll() method is used to add all elements of a list to vector in java.
Syntax:
boolean addAll(Collection C)
Example:
package com.w3schools; import java.util.ArrayList; import java.util.List; import java.util.Vector; public class Test { public static void main(String args[]){ Vector<String> vector = new Vector<String>(); //adding elements to the end vector.add("Jai"); vector.add("Mahesh"); vector.add("Hemant"); vector.add("Vishal"); System.out.println("Actual vector:"+vector); List<String> list = new ArrayList<String>(); list.add("Vievk"); list.add("Naren"); vector.addAll(list); System.out.println("After adding: "+vector); } } |
Output
Actual vector:[Jai, Mahesh, Hemant, Vishal] After adding: [Jai, Mahesh, Hemant, Vishal, Vievk, Naren] |