baidu_19694879 2016-03-23 07:54 采纳率: 50%
浏览 1732
已采纳

android异常 ConcurrentModificationException()

要进行的操作是,遍历map.判断key值是否存在。如果存在,,则this key对应的valuez增加一个list,否则的话,就重新再添加一组键值对,

private Map> modleLists() {
List lists = new ArrayList();
Map> maps = null;
for (int i = 0; i < carInfoLists.size(); i++) {
if (maps == null) {
maps = new HashMap>();
lists.add((carInfoLists.get(i)));
maps.put(carInfoLists.get(i).getModleName(), lists);
} else {
Iterator>> it = maps.entrySet().iterator();
while (it.hasNext()) {
Entry> next = it.next();
String key = next.getKey();
if (carInfoLists.get(i).getModleName().equals(key)) {
CarModle carModle = carInfoLists.get(i);
maps.get(key).add(carModle);
} else {
lists.clear();
lists.add(carInfoLists.get(i));
maps.put(carInfoLists.get(i).getModleName(), lists);
}

            }
  • 写回答

5条回答

  • baidu_19694879 2016-04-19 09:11
    关注

    谢谢给位,自己已解决

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器