Two comments here:
1) How is that "deep copy" code sample a deep copy? When I think of deep copying, I think of taking an array of references and allocating a copy of each element and storying that in the new array. You would recursively do this for each non-primitive field in each object in the array as well. In this case, it's just a normal array copy. I'm not sure why they called it a deep copy.
2) In your example, you're increasing the size of the array by 1 each time, so you do have to copy the array each time you add an element to it. In reality you would increase the size of the array by a larger amount so you wouldn't have to copy it with each insertion. This is what ArrayList does under the covers, as do other dynamically sized array implementations. A typical strategy is to double the size of the array each time you have to resize it.
1) How is that "deep copy" code sample a deep copy? When I think of deep copying, I think of taking an array of references and allocating a copy of each element and storying that in the new array. You would recursively do this for each non-primitive field in each object in the array as well. In this case, it's just a normal array copy. I'm not sure why they called it a deep copy.
2) In your example, you're increasing the size of the array by 1 each time, so you do have to copy the array each time you add an element to it. In reality you would increase the size of the array by a larger amount so you wouldn't have to copy it with each insertion. This is what ArrayList does under the covers, as do other dynamically sized array implementations. A typical strategy is to double the size of the array each time you have to resize it.