Modifying Primitives in an Enhanced For-Loop
What does the code print when executed?
public class ModifyMatrix {
public static void main(String[] args) {
int[][] matrix = { {1,2}, {3,4} };
for (int[] row : matrix) {
for (int n : row) {
n = n + 5;
}
}
System.out.print(matrix[0][0] + " " + matrix[1][1]);
}
}
A
1 9
B
1 4
C
6 9
D
6 4
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE