【发布时间】:2012-07-09 14:14:35
【问题描述】:
我在下一行得到一个错误。 我正在做添加到 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());
【问题讨论】:
-
到目前为止你尝试过什么?你读过 ConcurrentModificationException 的 JavaDoc 吗?
-
您是否遗漏了一些代码,在这些代码中您实际上也在迭代要添加项目的 JSONArray?
标签: java exception arrays concurrentmodification