相关疑难解决方法(0)

如何解决此错误java.util.ConcurrentModificationException

我在下一行收到错误.我正在做添加到jsonarray的过程.请帮我.

jsonArr=new JSONArray();
if(req.getSession().getAttribute("userses")!=null){
    String name=(req.getParameter("name")==null?"":to_EnglishName(req.getParameter("name").toUpperCase()));
    if(!name.equals("")){
        for(Book c:GlobalObjects.bookList){
            if(c.getBookName().startsWith(name)){
                    jsonObjec=new JSONObject();
                    jsonObjec.put("label",c.getBookName());
                    jsonObjec.put("value", c.getId());
                    jsonArr.add(jsonObjec);//java.util.ConcurrentModificationException
            }
        }
    }
}
jsonArr.write(res.getWriter());
Run Code Online (Sandbox Code Playgroud)

java arrays exception concurrentmodification

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

标签 统计

arrays ×1

concurrentmodification ×1

exception ×1

java ×1