Java examples for Collection Framework:ArrayList
To append all elements of another Collection to ArrayList use boolean addAll(Collection c) method.
import java.util.ArrayList; import java.util.Vector; public class Main { public static void main(String[] args) { ArrayList<String> arrayList = new ArrayList<>(); arrayList.add("1"); arrayList.add("2"); arrayList.add("3"); Vector v = new Vector(); v.add("4");/*from w w w . j a va 2 s . c om*/ v.add("5"); // append all elements of Vector to ArrayList arrayList.addAll(v); System.out.println(arrayList); } }