public static void main(String[] args) throws Exception{
Map<String,Object> aa=new HashMap<String, Object>();
aa.put("a1","a1");
aa.put("a2","a2");
aa.put("a3","a3");
aa.put("a4","a4");
Set<String> ss=aa.keySet();
Iterator it=ss.iterator();
while(it.hasNext()){
Object key=it.next();
if("a1".equals(key)){
aa.put("aa1","aa1");
}
}
System.out.println(aa);
}
报错如下:

Exception in thread "main" java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1437)
at java.util.HashMap$KeyIterator.next(HashMap.java:1461)

Map遍历增加key报错如何解决的更多相关文章

  1. mysql中大数据表alter增加字段报错:"1034 Incorrect key file for table 'table_name'; try to repair it"

    mysql中大数据表alter增加字段报错:"1034 Incorrect key file for table 'table_name'; try to repair it" 现 ...

  2. Eclipse中利用JSP把mysql-connector-java-8.0.13.jar放到WebContent\WEB-INF\lib中连接MySQL数据库时Connection conn = DriverManager.getConnection(url,username,password)报错的解决办法

    开发环境: 1.系统:windows 7/8/10均可 2.jdk:1.8.0_144 3.服务器:apache-tomcat-9.0.8 4.IDE:eclipse+jsp 0.网页代码如下: &l ...

  3. Springboot数据库连接池报错的解决办法

    Springboot数据库连接池报错的解决办法 这个异常通常在Linux服务器上会发生,原因是Linux系统会主动断开一个长时间没有通信的连接 那么我们的问题就是:数据库连接池长时间处于间歇状态,导致 ...

  4. window7下安装第三方包报错及解决

    window7 64位下安装第三方包,,比如安装yaml的exe执行文件,会 报错及解决:python version 2.7(3.4) required,which was not found in ...

  5. pom.xml里有红叉报错的解决办法

    pom.xml里有红叉报错的解决办法一: 1.把鼠标点在报的错上发现pom.xml报如下错误: Multiple annotations found at this line: - Failure t ...

  6. eclipes的Spring注解SequenceGenerator(name="sequenceGenerator")报错的解决方式

    eclipes的Spring注解SequenceGenerator(name="sequenceGenerator")报错的解决方式 右键项目打开Properties—>JA ...

  7. Can't bind to local 8700 for debugger报错和解决

    [2016-02-15 22:37:17 - ddms] Can't bind to local 8700 for debugger报错和解决 1.打开studio monitor是出错: Can't ...

  8. Loadrunner参数化连接oracle、mysql数据源报错及解决办法

    Loadrunner参数化连接oracle.mysql数据源报错及解决办法 (本人系统是Win7 64,  两位小伙伴因为是默认安装lr,安装在 最终参数化的时候,出现连接字符串无法自动加载出来: 最 ...

  9. ArcGIS API for Silverlight 调用WebService出现跨域访问报错的解决方法

    原文:ArcGIS API for Silverlight 调用WebService出现跨域访问报错的解决方法 群里好几个朋友都提到过这样的问题,说他们在Silverlight中调用了WebServi ...

  10. PHP empty函数报错的解决办法

    PHP empty函数在检测一个非变量情况下报错的解决办法. PHP开发时,当你使用empty检查一个函数返回的结果时会报错:Fatal error: Can't use function retur ...

随机推荐

  1. from pathlib import Path

    from pathlib import Path #引入库 P.parent #获取父级目录 P.exists() #判断当前路径是否存在 P.mkdir(parents=Fasle) # 根据路径创 ...

  2. 一步一步教你FasterRunner在Centos7服务器部署

    一,搭建环境的安装版本 centos ,mysql-5.7.22,node-v9.8.0,Python-3.6.2(注意mysql版本,因为django需要跟mysql兼容) 二,linux 环境的搭 ...

  3. python菜鸟学习: 3.浅copy使用场景

    # -*- coding: utf-8 -*-import copy# 浅copy# 使用场景,比如A,B夫妻共有一个银行账户,存取马宁的数据username = ["name", ...

  4. OutLook从excel导入联系人

    1.将已有的excel打开-->另存为-->csv格式 2.用记事本打开 .CSV 文件,选择"文件"-"另存为",修改为  ANSI编码后,然后导 ...

  5. SpringMVC-nfjh

    SpringMVC springmvc项目创建 1.使用maven创建web项目结构 2.补充更改结构 3.springmvc-config.xml 1)添加包扫描(context命名空间) 2)添加 ...

  6. STM32工程建立

    STM32工程建立 对于用keil5建立stm32工程有两种方法,一种在学习过程中比较方便的建立方式:我们称为工程方式一,另一个便是在实际工程中用的最多,也最普遍,在实际过程中用的最多的,我们称为工程 ...

  7. EF getCookie

    table class="table table-bordered"> <thead> <tr> <td>商品名称</td> ...

  8. Vue3父组件调用子组件内部的方法

    1. 子组件中定义方法并通过defineExpose暴露出去 import { reactive, defineExpose } from "vue"; const state = ...

  9. Vue RSA加密

    1. 安装jsencrypt npm install jsencrypt 2. 引入jsencrypt // 全局引入 import JSEncrypt from "jsencrypt&qu ...

  10. Transformer_Detection-(DETR) 引入视觉领域的首创DETR (ECCV2020)

    End-to-End Object Detection with Transformers paper: https://link.zhihu.com/?target=https%3A//arxiv. ...