Question: Consider the following method. For each multi-dimensional array listed below, write the final array state that would result if the given array were passed as

Consider the following method. For each multi-dimensional array listed below, write the final array state that would result if the given array were passed as a parameter to the method.

public void array2dMystery2(int[][] a) {
 for (int r = 0; r < a.length; r++) {
 for (int c = a[0].length - 2; c > 0; c--) {
 a[r][c] = a[r][c - 1] + a[r][c + 1];
 }
 }
}

the 2 inputs needed:

int[][] a1 = {{2, 1, 6}, {5, 8, 9}, {1, -5, -4}};
int[][] a2 = {{1, 2, 3, 4, 5}, {2, 4, 6, 8, 10}, {0, 1, 2, 3, 4}};

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!