Add all elements of a Collection to Java ArrayList Example

In this example we will learn how to add a entire collection to a  Java ArrayList. we will follow the below steps.

  • First step is that we need to create a new ArrayList.
  • Populate the ArrayList al1 with elements, using add(E e) API method of ArrayList.
  • Create a new ArrayList al2 and add elements to it using add(E e) method.
  • Using addAll(Collection c) we will add all the elements of al2 to al1

[Read more…]