索引超出了界限,但我不知道在哪里



这些是我的代码片段,但我一直收到同样的错误,我不知道为什么。

我一直收到

线程中的异常";主";java.lang.ArrayIndexOutOfBoundsException:索引2超出长度2 的界限

语法。(Grammar.java:92(

我可以看出这可能与数组大小有关,但我不知道在哪里。

提前谢谢你,如果有人能帮助我,我将不胜感激。

public int getInit() {
return init;
}
int max = 100;
int[][] ntr = new int[max][0];
NTR tempo = nttemp.remove(0); // NTR is another class that contains only gets
int tempoF = tempo.getFirst();
int tempoS = tempo.getSecond();

int i = 1;
92 ntr[tempo.getInit() - 'A'][i] = tempoF;
i++;
ntr[tempo.getInit() - 'A'][i] = tempoS;
i++;

创建一个零大小的数组。无论何时尝试为其添加下标,都会超出范围,因为零长度数组(无论类型如何(都没有有效的索引。

相关内容

最新更新