ArrayList addAll(Collection c) Method example

http://blipsystems.com/mikluxa/611 female comedian hosts dating show http://www.iziart.cz/?filmec=actors-dating-musicians&617=78 best hookup sites canada free source link source url http://lokoli.com/?rtyt=site-rencontre-musulman-france-gratuit&9ea=86 site rencontre pour jeune source site ArrayList addAll(Collection c) Method example

This method is used for adding all the elements of a list to the another list.

Syntax: public boolean addAll(Collection c)

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

Example:

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

  }

}

Output:

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