map遍历时报错信息 ConcurrentModificationException

173 阅读1分钟
 for (String key : mapTypes.keySet()) {
                //循环遍历字段说明MAP,结果map中是否有那个key,如果有赋值
                for (String key1 : commentKeyToCamel.keySet()) {// 数据库的值
                    //比较两个map的key,赋值
                    boolean containsKey = mapTypes.containsKey(key1);
                    if (containsKey) {
                        mapTypes.put((String) commentKeyToCamel.get(key1),commentKeyToCamel.remove(key));
                        System.out.println("测试测试测试key" + (String) commentKeyToCamel.get(key1));
                        System.out.println("JsonMap02.get(key)" + mapTypes.get(key));
                    } else {
                        System.out.println("Map中包含名为:" + key + "的key");
                    }
                }
            }