Table of contents
Open Table of contents
1. Constructor
List<T> copy = new ArrayList<>(list);
2. AddAll
List<T> copy = new ArrayList<>();
copy.addAll(list);
3. Collections.copy
List<Integer> source = Arrays.asList(1, 2, 3);
List<Integer> dest = Arrays.asList(5, 6, 7, 8, 9, 10);
Collections.copy(dest, source);
4. Using Stream in Java 8
List<String> copy = list.stream().collect(Collectors.toList());
5. In Java 10
List<T> copy = List.copyOf(list);