这些是我的代码片段,但我一直收到相同的错误,我不知道为什么。
我不断地得到
线程"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++;发布于 2020-09-15 02:01:47
您可以创建一个大小为零的数组。无论何时尝试下标,它都会超出界限,因为对于零长度数组(无论是什么类型)都没有有效的索引。
https://stackoverflow.com/questions/63889511
复制相似问题