logo CodeStepByStep logo

arrayMysteryExam6

Language/Type: Java arrays

Write the output produced by the following method when passed each of the following arrays:

public static void arrayMysteryExam6(int[] a) {
    for (int i = 1; i < a.length - 1; i++) {
        a[i] = a[i - 1] + a[i + 1];
        if (a[i] % 2 == 0) {
            a[i] = a[i] / 2;
        }
    }
    System.out.println(Arrays.toString(a));
}
{1, 3, 4, 6}
{8, 13, 0, 6, 11, 2}

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.