You have a ;
after your last for
, so after the for
executes with no additional commands in each step, the variable i
will have the value students.length
which is outside the bounds of the array. Then the { ... }
block following the for is executed once with that final value of i
, causing the exception.
Remove that ;
and it should work.