小编mav*_*rav的帖子

ArrayList.add抛出ArrayIndexOutOfBoundsException

我试图将一个对象添加到ArrayList并抛出ArrayIndexOutOfBoundsException以下是代码

private void populateInboxResultHolder(List inboxErrors){
    inboxList = new ArrayList();
    try{                
        inboxHolder = new InboxResultHolder();
        //Lots of Code
        inboxList.add(inboxHolder);
    }catch(Exception e){
        e.printStackTrace();
    }
}
Run Code Online (Sandbox Code Playgroud)

例外是

[3/7/12 15:41:26:715 UTC] 00000045 SystemErr     R java.lang.ArrayIndexOutOfBoundsException
[3/7/12 15:41:26:721 UTC] 00000045 SystemErr     R      at java.util.ArrayList.add(ArrayList.java:378)
[3/7/12 15:41:26:721 UTC] 00000045 SystemErr     R      at com.ml.fusion.ui.common.web.bean.inbox.InboxSearchBean.populateInboxResultHolder(InboxSearchBean.java:388)    
[3/7/12 15:41:26:721 UTC] 00000045 SystemErr     R      at com.ml.fusion.ui.common.web.bean.inbox.InboxSearchBean.searchInboxErrors(InboxSearchBean.java:197)
[3/7/12 15:41:26:721 UTC] 00000045 SystemErr     R      at com.ml.fusion.ui.common.web.bean.inbox.InboxSearchBean.viewInbox(InboxSearchBean.java:207)
Run Code Online (Sandbox Code Playgroud)

但是根据ArrayList.add的签名,它不应该抛出这个异常.请帮忙.

java indexoutofboundsexception

16
推荐指数
1
解决办法
1万
查看次数

如何实现java"this"关键字?

this指针如何指向对象本身?它是java实现还是编译器实现?

java

6
推荐指数
2
解决办法
442
查看次数

为什么伪对象作为块级同步的参数传递?

在Spring源代码中找到了这段代码.这是将XML文件转换为Bean Tree的第一步.

/** Synchronization monitor for the "refresh" and "destroy" */
    private final Object startupShutdownMonitor = new Object();

public void refresh() throws BeansException, IllegalStateException {
        synchronized (this.startupShutdownMonitor) {
            // Prepare this context for refreshing.
            prepareRefresh();
}
Run Code Online (Sandbox Code Playgroud)

java multithreading synchronized

2
推荐指数
1
解决办法
1199
查看次数