如何输出数组中的标记?

时间:2014-04-08 00:48:16

标签: java arrays

当我尝试显示标记时,BlueJ不断返回java.lang.ArrayIndexOutOfBoundsException。

for (index = 0; index < assignmentLimit; index++)
    {  
        System.out.println("\nAssigment " + (index + 1) + " marks:");
        for (indexTwo = 0; indexTwo < studentLimit; indexTwo++)
        {
            System.out.print("\nMark " + (indexTwo + 1) + ": ");
            String input = console.readLine();
            mark[grade][indexTwo] = Integer.parseInt(input);
        }
    }
System.out.print("\n\t" + mark[grade][indexTwo]);

1 个答案:

答案 0 :(得分:0)

由于您首先迭代index,然后再indexTwo,我猜您真的想要这样做:

mark[index][indexTwo] = Integer.parseInt(input);