My question is how to make a deep copy in java. Right now this is my code but I don't think this is correct.
@Override
public ListInterface<E> copy() {
ListerInterface<E> temp = new List<E>();
if (isEmpty()) {
return null;
} else {
goToFirst();
do {
temp.inset(retrieve());
} while (currentNode.next != null);
currentNode = currentNode.next;
}
return temp;
}
So does anybody know what I should change in my code to get a deep copy that is correct?