How to join two ArrayList in Java - Example

You can use the addAll() method from java.util.Collection interface to join two ArrayLists in Java. Since ArrayList implements List interface which actually extends the Collection interface, this method is available to all List implementation including ArrayList e.g. Vector, LinkedList. The Collection.addAll(Collection src) method takes a collection and adds all elements from it to the collection which calls this method e.g. target.addAll(source). After this call, the target will have all elements from both source and target ArrayList, which is like joining two ArrayList in Java. The second ArrayList will remain as it is but the first ArrayList on which you have added elements will have more elements. Its size will be equal to the sum of the size of first and second ArrayList.
Read more »