Question: Deep Copying Arrays a) Below main, create a new method called cloneArray that takes an array of integers as a parameter, creates a new array
Deep Copying Arrays
a) Below main, create a new method called cloneArray that takes an array of integers as a parameter, creates a new array that is the same size as the parameter, copies the elements from the first array into the new one, and then returns a reference to the new array.
b) Back in the Problem 7 section in main, create an int array named array3 with the values 1, 2, 3, 4, 5.
c) Declare an int array array4 and assign it the clone of array3, using your cloneArray method.
d) Display array3 and array4. They should have the same values.
e) change element 0 of array4 to 99.
f) display array3 and array4. array4's first element is 99, but array3's first element did not change.
Expected Result: Problem 7 0:1 1:2 2:3 3:4 4:5
0:1 1:2 2:3 3:4 4:5
0:1 1:2 2:3 3:4 4:5
0:99 1:2 2:3 3:4 4:5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
