Namely, without referencing the same object, I need to copy values of elements of one list into another list. These are the lists:
List<Integer> listA = new ArrayList<Integer>();
List<Integer> ListB = new ArrayList<Integer>();
listA = (added some values);
listB = (do what?)...
PS. I appologize for beginner’s question, but I have never done such a thing.
You can try and give a look at the Collections.copy method:
Note: The above should work for simple data types such as Integers, however, if you have your own objects which might in turn reference other objects, you will have to iterate over each object and copy it separately.