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
Get step-by-step solutions from verified subject matter experts
