Why do you need a 2D array for a list of grades? Someone could help if you showed an example of how your 2d array is formatted.
Right now, based off that small snippet, it seems your outer array has length less than each inner array, so your outer array goes out of bounds in the loop.