logo Practice-It logo


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

Write a method named stutter that accepts an array of integers as its parameter and returns a new array with two consecutive copies of each value from the original array. You may assume that the array passed is not null.

For example, if the following array is passed:

int[] a = {11, -4, 0, 777};
int[] stuttered = stutter(a);

After the call, the array stuttered should store the elements {11, 11, -4, -4, 0, 0, 777, 777}. You should not modify the array that is passed in.

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.