Is it possible to add the elements of one Arraylist to another Arraylist? For example if an Arraylist has elements 3,6,3,8,5 in index 0,1,2,3,4, now I want to add 3,6,3,8,5 to another ArrayList in index 0, is it possible?
ArrayList<String> num = new ArrayList<String>();
num.add("3");
num.add("6");
num.add("3");
num.add("8");
num.add("5");
ArrayList<String> result = new ArrayList<String>();
for (int i = 0; i < num.size(); i++)
{
result.addAll(i,num);
}
I have tried this but it is not working.
what i want is when i try System.out.println(result.get(0));
result must be [3 6 3 8 5].