Hallo, das sollte eigentlich ziemlich einfach sein, trotzdem weiß ich nicht, warum eine Exception geworfen wird.
Das hatte ich zuerst. Im Internet stand, man solle Iterator benutzen, das habe ich dann gemacht:
Das wirft jedoch die gleiche Exception aus.
Die Exception ist checkForComodification.
Was muss ich ändern?
Java:
public static ArrayList<Node> clone(final ArrayList<Node> step) {
ArrayList<Node> arr = new ArrayList<>();
for (Node n : step)
arr.add(n.clone());
return arr;
}
Das hatte ich zuerst. Im Internet stand, man solle Iterator benutzen, das habe ich dann gemacht:
Java:
public static ArrayList<Node> clone(final ArrayList<Node> step) {
ArrayList<Node> arr = new ArrayList<>();
Iterator<Node> it = step.iterator();
while (it.hasNext()) {
arr.add(it.next().clone());
}
return arr;
}
Das wirft jedoch die gleiche Exception aus.
Die Exception ist checkForComodification.
Was muss ich ändern?