Collections.addAll(Collection <? super T> c, T... elements) has the following syntax.
@SafeVarargs public static <T> boolean addAll(Collection <? super T> c, T... elements)
In the following code shows how to use Collections.addAll(Collection <? super T> c, T... elements) method.
//from w ww . j a va2s .c om import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Main { public static void main(String args[]) { List<String> arrlist = new ArrayList<String>(); arrlist.add("A"); arrlist.add("B"); arrlist.add("C"); arrlist.add("from java2s.com"); System.out.println(arrlist); // add values to this collection boolean b = Collections.addAll(arrlist, "1","2","3"); System.out.println(arrlist); } }
The code above generates the following result.