How to add all elements of a list to vector?

Below example shows how to copy or create a vector with another collection object. In this code we have created an ArrayList and by using addAll() method, we can copy to vector object.

package test;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
 
public class ListToVector {
 
    public static void main(String a[]){
        Vector<String> vct = new Vector<String>();
        //adding elements to the end
        vct.add("Selenium");
        vct.add("Java");
        vct.add("UFT");
        vct.add("Other");
        System.out.println("Actual vector:"+vct);
        List<String> list = new ArrayList<String>();
        list.add("Testing");
        list.add("Development");
        vct.addAll(list);
        System.out.println("After Copy: "+vct);
    }
}

Output:

Actual vector:[Selenium, Java, UFT, Other]
After Copy: [Selenium, Java, UFT, Other, Testing, Development]

The only business I know is learning new technology and spreading the knowledge. I believe sharing is learning. This is my prime reason to build this site.
I welcome and value your comments, suggestions and corrections.

200total visits,2visits today

The only business I know is learning new technology and spreading the knowledge. I believe sharing is learning. This is my prime reason to build this site. I welcome and value your comments, suggestions and corrections.