Grokking Java Interview Questions
0% completed
Copying Objects
A copy is a second object that holds the same values as the first one, so that a change to one of them does not appear in the other. The statement copy = order does not create a copy. It gives one object a second name, and every change is visible through both names.
Between these two results lies a third one: a new object whose fields refer to the same inner objects as the original. Such a copy is only partly independent, and it is the result of Object.clone() and of Arrays.copyOf() on an array of objects.
This lesson defines the two kinds of copy, examines `clone()
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%