// CSE 143, Winter 2009, Marty Stepp // This program was written in class to test the stutter method. // import java.util.*; public class Stutter { // This method accepts an array of integers as its parameter and returns // a new array containing two copies of each value from the parameter. // For example, when passed {2, -3, 7}, it returns {2, 2, -3, -3, 7, 7}. public static int[] stutter(int[] a) { int[] result = new int[a.length * 2]; for (int i = 0; i < a.length; i++) { result[2 * i] = a[i]; result[2 * i + 1] = a[i]; } return result; } // tests the stutter method public static void main(String[] args) { int[] a = {4, 7, -2, 15, 6}; int[] a2 = stutter(a); System.out.println(Arrays.toString(a2)); } }