What would be the last valid index for this array?
double[][] array = new double[11][17];
What would be the last valid index for this array?
double[][] array = new double[11][17];
The answer is [10][16], let's see how in code.
public static void main(String[] args) {
double[][] array = new double[11][17];
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
System.out.printf("[%d][%d]%n", i, j);
}
}
}
And the last line of output is
[10][16]
Or, you could remember that array indexes start at 0 and the last element of an array is at the length of the array - 1.