the simplest way to copy a List is to pass it to the constructor of the new list:
List<String> b = new ArrayList<>(a);
b
will be a shallow copy of a
Looking at the source of Collections.copy(List,List)
(I'd never seen it before) it seems to be for coping the elements index by index. using List.set(int,E)
thus element 0 will over write element 0 in the target list etc etc. Not particularly clear from the javadocs I'd have to admit.
List<String> a = new ArrayList<>(a);
a.add("foo");
b.add("bar");
List<String> b = new ArrayList<>(a); // shallow copy 'a'
// the following will all hold
assert a.get(0) == b.get(0);
assert a.get(1) == b.get(1);
assert a.equals(b);
assert a != b; // 'a' is not the same object as 'b'