With 2 ArrayList, I was wondering if the best way to turn the 1st into a “copy” of the second is to go like
myFirstArray.clear(); myFirstArray.addAll(mySecondArray);
or
myFirstArray = mySecondArray.clone();
What are the main differences between the two methods, which are preferred and there is another “lighter” or “cleaner” solution. Thanks for any advice.
EDIT: I use this copy to replace the array of the im element, which currently works with where I store the element that I will work with in the next loop. At the end of the loop, I replace my currentArrayList with my futurArrayList, and I clear my futurArraylist to add a new element to it (I hope it is clear enough)
java
Wizliz
source share