Java 2D Array Initialization Syntax
Which error stops this code from compiling?
public class ArrayError {
public static void main(String[] args) {
int[][] numbers = new int[2,3];
System.out.println(numbers[0][0]);
}
}
A
The main method is not defined as static.
B
The variable ‘numbers’ is not properly initialized.
C
The print statement is missing a semicolon at the end.
D
The array is declared with incorrect syntax using a comma instead of separate square brackets for each dimension.
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE