为什么我收到此错误?我不明白..这是抛出异常的代码
public static final int getItemDefinitionsSize(Store store) {
int lastArchiveId = store.getIndexes()[19].getLastArchiveId();
return lastArchiveId * 256
+ store.getIndexes()[19].getValidFilesCount(lastArchiveId);
}
这是例外本身。
java.lang.ArrayIndexOutOfBoundsException: 19
at com.alex.Utils.getItemDefinitionsSize(Utils.java:50)
at Kjs.Application.addAllItems(Application.java:186)
at Kjs.Application.initialize(Application.java:182)
at Kjs.Application.<init>(Application.java:52)
at Kjs.Application$1.run(Application.java:39)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Press any key to continue . . .
答案 0 :(得分:1)
在下面一行
int lastArchiveId = store.getIndexes()[19].getLastArchiveId();
您正试图从那里获取不存在的值。这意味着您访问的数组的长度低于19。
但是你必须在发布之前做好你的作业。