Java 如何在数组中输出标记?
当我尝试显示标记时,BlueJ会不断返回java.lang.ArrayIndexOutOfBoundsExceptionJava 如何在数组中输出标记?,java,arrays,Java,Arrays,当我尝试显示标记时,BlueJ会不断返回java.lang.ArrayIndexOutOfBoundsException for (index = 0; index < assignmentLimit; index++) { System.out.println("\nAssigment " + (index + 1) + " marks:"); for (indexTwo = 0; indexTwo < studentLimit; ind
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]);
for(索引=0;索引
既然您先迭代索引
,然后迭代索引两个
,我想您真的想这样做:
mark[index][indexTwo] = Integer.parseInt(input);
考虑升级到一个真正的IDE并使用调试器。或者,用笔和纸来跟踪执行情况。我必须使用BlueJ,因为这是我的学校让我使用的。(在适当的IDE中测试你的代码,并在代码正确时将其复制到BlueJ。)此外,请阅读什么是
ArrayIndexOutOfBoundsException
。Java有一个名为Javadoc的文档特性。变量等级和学生限制是什么?最可能的问题在于循环超出了数组界限。