【发布时间】:2014-01-07 23:05:44
【问题描述】:
我似乎找不到以下错误的问题:
线程“主”java.lang.ArrayIndexOutOfBoundsException 中的异常:31
在这部分代码中收到此错误:
for (int i = 0; i < templateKeuze.length(); i++) {
if(woord[i].startsWith("?")){
System.out.println("\nGeef je input voor de parameter "+woord[i]);
vervang = Input.readLine();
templateKeuze.replace(woord[i],vervang);
} else{
continue;
}
}
【问题讨论】:
-
woord的长度是多少?请注意,如果templateKeuze是String,则字符串是不可变的,因此您应该使用templateKeuze = templateKeuze.replace(woord[i],vervang);。 -
天哪,我只是智障,一直在寻找这个一个小时,猜是因为我累了。它必须是“word.length()”我的错。对不起。感谢您的回答,请随时将其发布为答案
-
将
templateKeuze.length()更改为woord.length() -
你可以删除这个问题。这不会为该网站增加更多价值。
-
@ZouZou 我认为他可以给出答案
标签: java indexoutofboundsexception