How to add all elements of a list to vector?

Continue 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.

find 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); } }

resource Output:

rencontre tg

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

rencontres dans le 04