as I understood, the method clone() gives us the ability to copy object (no refernce) in Java. But I also read, that the copy is shallow. So what the point? Which ability the clone() method gives me, that a simple assingment doesn’t?
as I understood, the method clone() gives us the ability to copy object (no
Share
The difference is that you can modify the cloned object without modifying the original object.
The change on
p3does feed back top, while the change onp2does not.Let’s see how the situation is after the individual statements (assuming
1,2,5,7would be objects):