You have defined the size of your array int[][]aryStudent = new int [5][4];
to be 5 and you are going from 0 to 5 (which is 6)
aryStudent[5][0] = Integer.parseInt(test1Field.getText());
aryStudent[5][1] = Integer.parseInt(test2Field.getText());
aryStudent[5][2] = Integer.parseInt(test3Field.getText());
aryStudent[5][3] = Integer.parseInt(test4Field.getText());
As suggested in the comments, use an ArrayList
. The advantage with an ArrayList
is that they dynamically grow in size so you don't have to worry about the maximum size.
Or, the best way IMHO, would be to use a HashMap
Example:
HashMap<Integer, Integer> studentsMarks = new HashMap<Integer, Integer>();
//To insert
studentsMarks.put(//key, //value);
//To retrive
studentMarks.get(//key);