Invalid 2D Array Index Type
What is the cause of the compilation error in the provided code segment?
public class IndexError {
public static void main(String[] args) {
int[][] table = { {1, 2, 3}, {4, 5, 6} };
int element = table['0'][1];
System.out.println(element);
}
}
A
Incorrect use of the System.out.println method.
B
Improper dimensions used when declaring the 2D array.
C
Using a character literal ‘0’ as an array index instead of an integer.
D
The array ‘table’ is not properly declared.
Question Leaderboard
Not enough data yet to show leaderboard.
