ArrayList addAll(Collection c) Method example ArrayList addAll(Collection c) Method example

browse around these guys This method is used for adding all the elements of a list to the another list.

50 primeras citas online espaа“ТБol youtube Syntax: public boolean addAll(Collection c)

reference It adds all the elements of specified Collection c to the current list.

discover this info here Example:

her explanation package ArraylistClass; import java.util.ArrayList; public class AddAllMethodExample { public static void main(String[] args) { // ArrayList1 of String type ArrayList<String> al = new ArrayList<String>(); al.add("C++"); al.add("Java"); al.add("C#"); al.add("SQL"); System.out.println("ArrayList1 before addAll:"+al); //ArrayList2 of String Type ArrayList<String> al2 = new ArrayList<String>(); al2.add("Delhi"); al2.add("Mumbai"); al2.add("Chennai"); al2.add("Bangalore"); //Adding ArrayList2 into ArrayList1 al.addAll(al2); System.out.println("ArrayList1 after addAll:"+al); } }

site link Output:

ArrayList1 before addAll:[C++, Java, C#, SQL]
ArrayList1 after addAll:[C++, Java, C#, SQL, Delhi, Mumbai, Chennai, Bangalore]