public boolean addAll(Collection c);
See Example :
import java.util.ArrayList;
import java.util.Collections;
public class Details {
public static void main(String args[]) {
// first Array
ArrayList<String> firstArr = new ArrayList<String>();
firstArr.add("Item8");
firstArr.add("Item3");
firstArr.add("Item5");
firstArr.add("Item6");
//second array
ArrayList<String> secondArr = new ArrayList<String>();
secondArr .add("Item1");
secondArr .add("Item2");
secondArr .add("Item3");
secondArr .add("Item4");
//create new Array to contain after combine 1 and 2
ArrayList<String> thirdArr = new ArrayList<String>();
thirdArr.addAll(firstArr);
thirdArr.addAll(secondArr);
System.out.println("Add All first array and second array ");
for(String arr : thirdArr){
System.out.println(arr);
}
}
}
//result :
Add All first array and second array
Item8
Item3
Item5
Item6
Item1
Item2
Item3
Item4
Item8
Item3
Item5
Item6
Item1
Item2
Item3
Item4
EmoticonEmoticon