我正在尝试获取466
arrayList的索引minuteList
[288, 318, 346, 376, 406, 436, 466, 1006, 1036, 1066, 1096, 1126, 1156]
但我收到此错误:
java.lang.IndexOutOfBoundsException: Index: 466, Size: 13
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at com.pdf.PDF.refill_time_table(PDF.java:155)
at com.pdf.PDF.main(PDF.java:54)
我已经调试了它,并且minuteList
具有上面的值以及变量element
具有的值466
。我该如何解决?
感谢您的帮助。
码:
Collections.sort(diffArray);
int element = diffArray.get(diffArray.size() - 1).getElement();
int nextElement = diffArray.get(diffArray.size()-1).getNextElement();
//the error occur after this line.
minuteList.get(element);
minuteList.get(element);
为您提供其索引为的元素,该元素element
在您的索引中不存在ArrayList
(只有13个元素的索引从0到12)。因此IndexOutOfBoundsException
。
你需要minuteList.indexOf(element)
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句