I'm trying to make a small app to practice 2D arrays. I basically want to collect grades and then compute the maximum and minimum grade.
However when I run the code I get an ArrayIndexOutOfBoundsException: error, which points to this segment of code:
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= 10; j++) {
results[i][j] = Double.parseDouble(JOptionPane.showInputDialog(null, "Please enter the " + (i + 1) + " result for the " + (j + 1) + " student."));
}
}
This is where I collect the user input.
Here is where I setup the array.
double max, min;
double results[][];
results = new double[3][10];
So, as I am not getting any errors, I'm not sure what the cause is. It seems I'm trying to access something that isn't available, but how come it can't be accessed?