ArrayList.addAll(Collection <? extends E > c) has the following syntax.
public boolean addAll(Collection <? extends E> c)
In the following code shows how to use ArrayList.addAll(Collection <? extends E > c) method.
// w w w. j a va2s . c o m import java.util.ArrayList; public class Main { public static void main(String args[]) { ArrayList<Integer> arrlist = new ArrayList<Integer> (5); arrlist.add(1); arrlist.add(2); arrlist.add(4); System.out.println(arrlist); ArrayList<Integer> arrlist2 = new ArrayList<Integer> (5); arrlist2.add(2); arrlist2.add(3); arrlist2.add(3); arrlist2.add(3); System.out.println(arrlist2); // inserting all elements arrlist.addAll(arrlist2); System.out.println(arrlist); } }
The code above generates the following result.