Hi, I basically have 1 arrayList with 10 elements.
//arraylist with10 elements
private ArrayList<String> arrayList1 = new ArrayList<String>();
//arraylist with nothing in it.
private ArrayList<String> arrayList2 = new ArrayList<String>();
public void copy() {
Collections.copy(arrayList1, arrayList2);
}
//The code above will copy all the elements in the first arraylist to the 2nd arraylist.
However the thing is....I need to copy many arraylists, if the user wants 5 arraylists I will have to create 5 arraylists and put all the arrayList1 elements in them. I don't know how to do this. Can any1 help me?
for(int i=0; i<5;i++){
//create new ArrayList each time
// copy all the elements from ArrayList1 to new ArrayList
}
I know the theory for it but dont know how to implement it. Can any1 help me? I have spent more than 2 hours on this.