-
Notifications
You must be signed in to change notification settings - Fork 0
java collection operations
gluehloch edited this page Nov 1, 2021
·
3 revisions
List<Integer> copy = new ArrayList<>(list);
List<Integer> copy = new ArrayList<>();
copy.addAll(list);
Achtung: Falls die Elemente der Liste veränderlich sind, hat eine Änderung an einem Element Auswirkungen auf beide Listen.
List<Integer> source = Arrays.asList(1,2,3);
List<Integer> dest = Arrays.asList(4,5,6);
Collections.copy(dest, source);
List<Integer> source = Arrays.asList(1, 2, 3);
List<Integer> dest = Arrays.asList(5, 6, 7, 8, 9, 10);
Collections.copy(dest, source);
by Andre Winkler 2021, Hamburg