2D Array Traversal Output
Consider the following code segment. What is printed when it is executed?
public class Main {
public static void main(String[] args) {
int[][] array = { {1, 2, 3}, {4, 5, 6} };
for (int[] row : array) {
for (int num : row) {
System.out.print(num + " ");
}
}
System.out.println();
}
}
A
1 2 3 4 5 6
B
4 5 6
C
Compilation Error
D
1 2 3
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #2 | y.seong2027 | 1 | 1 | 0m 29s | 71 |
| #3 | bommasam000 | 1 | 1 | 4m 32s | -172 |
Items per page:
10
1 – 3 of 3
APFIVE