2D Array Column Extraction
Consider the following code segment.
int[][] numbers = {{10, 20, 30}, {40, 50, 60}, {70, 80, 90}, {100, 110, 120}};
int[] myArr = mystery(numbers, 1);
for (int j: myArr)
System.out.print(j + " ");
public static int[] mystery(int[][] arr, int n)
{
int[] m = new int[arr.length];
for (int i = 0; i < arr.length; i++)
m[i] = arr[i][n];
return m;
}
What is printed as a result of executing the code segment?
A
40 50 60
B
10 40 70 100
C
20 60 80 110
D
20 50 80 110
Question Leaderboard
Not enough data yet to show leaderboard.
