【发布时间】:2020-09-14 17:58:25
【问题描述】:
这些是我的代码的 sn-ps,但我一直收到同样的错误,我不知道为什么。
我不断得到
线程“main”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++;
【问题讨论】:
-
请edit您的问题并发布您获得的整个堆栈跟踪。还要在文件
Grammar.java中发布第 92 行的文本。
标签: java arrays indexoutofboundsexception