logo Practice-It logo


Language/Type: Java arrays reference semantics
Author: Marty Stepp (on 2010/12/28)

Write a method named copyAll that accepts two arrays of integers as its arguments and copies the element values from the first array into the second array. For example, consider the following code:

int[] array1 = {2, 1, 4, 3, 6, 5};
int[] array2 = new int[6];
copyAll(array1, array2);

After your copyAll method executes, the array array2 should have the contents {2, 1, 4, 3, 6, 5} just like array1. You may assume that the second array is always at least as large in length as the first array.

Type your solution here:

This is a method problem. Write a Java method as described. Do not write a complete program or class; just the method(s) above.

You must log in before you can solve this problem.

Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.