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