2D Array Column-Major Traversal
Consider the following code segment:
String[][] data = {
{"AA", "BB"},
{"CC", "DD"},
{"EE", "FF"},
{"GG", "HH"}
};
for (int col = 0; col < data[0].length; col++) {
for (int row = 0; row < data.length; row++) {
System.out.print(data[row][col] + " ");
}
System.out.println();
}
What is printed as a result of executing this code segment?
A
CC AA
DD BB
FF EE
HH GG
B
AA CC EE GG
BB DD FF HH
C
BB FF DD HH
AA EE CC GG
D
AA CC EE GG
HH FF DD BB
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE