Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

=+ f. instituting laws against driving while intoxicated

Answered: 1 week ago

Question

=+ Why have these changes occurred?

Answered: 1 week ago