我已经创建了大小为45的ArrayList的数组。我出于某种原因而收到ArrayOutOfBoundException。ArrayIndexOutOfBoundsException ArrayList的数组
这里就是我得到的错误:
String temp;
Scanner sc = new Scanner(str1);
while(sc.hasNext())
{
temp = sc.next();
int len = temp.length();
if(len > 0)
wordsByLen[len - 1].add(temp); //throwing the error here with exception of 59
}
预先感谢您的帮助!
where wordsByLen defined – 2013-03-27 13:39:36
什么保证你'temp.length()'永远不会高于45?您正在阅读字符串,我可以看到 – 2013-03-27 13:40:13
我在类的构造函数中定义了wordsByLen。 – mkjo0617 2013-03-27 13:43:15