I have an ArrayList
l1
of size 10. I assign l1
to new list reference type l2
. Will l1
and l2
po
Another convenient way to copy the values from src ArrayList to dest Arraylist is as follows:
ArrayList<String> src = new ArrayList<String>();
src.add("test string1");
src.add("test string2");
ArrayList<String> dest= new ArrayList<String>();
dest.addAll(src);
This is actual copying of values and not just copying of reference.
Try to use Collections.copy(destination, source);