-9

为什么我会收到此错误?我不明白..这是引发异常的代码

  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 . . .
4

1 回答 1

1

在下面一行

int lastArchiveId = store.getIndexes()[19].getLastArchiveId();

您正在尝试从那里获取不存在的值。这意味着您正在访问的该数组的长度低于 19。

但是在发帖之前你必须做好功课。

于 2013-06-01T12:20:41.110 回答