See Example
import java.util.ArrayList;
public class Details {
public static void main(String args[]) {
ArrayList<String> arrlist = getArrayList();
}
public static ArrayList<String> getArrayList(){
// first Array
ArrayList<String> firstArr = new ArrayList<String>();
firstArr.add(" A1 : Item1");
firstArr.add(" A1 : Item2");
firstArr.add(" A1 : Item3");
firstArr.add(" A1 : Item4");
//second array
ArrayList<String> secondArr = new ArrayList<String>();
firstArr.add(" A2 : Item1");
firstArr.add(" A2 : Item2");
firstArr.add(" A2 : Item3");
firstArr.add(" A2 : 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("Combine or join first array and second array ");
for(String arr : thirdArr){
System.out.println(arr);
}
return thirdArr;
}
}
//result
Combine or join first array and second array
A1 : Item1
A1 : Item2
A1 : Item3
A1 : Item4
A2 : Item1
A2 : Item2
A2 : Item3
A2 : Item4
we used method java collections "addAll()" to contain all values of arraylist
EmoticonEmoticon