package test;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; public class Test { public static void main(String[] args) { List list = new ArrayList();
list.add("1");
list.add("2");
list.add("3"); Iterator iterator = list.iterator();
while(iterator.hasNext()){ Object next = iterator.next();
if(next.equals("2")){
list.add("5");
}else{
System.out.println(next);
}
}
System.out.println(list);
} }

Exception in thread "main" java.util.ConcurrentModificationException的更多相关文章

  1. Exception in thread "main" java.util.ConcurrentModificationException解决方案

    我想判断一个集合里面有没有"world"这个元素,如果有,我就添加一个"javaee"元素, 当时的做法是: public class ListIterator ...

  2. Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 0 [ ^

    Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character clas ...

  3. Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 0 解决方法: 要对切割字符进行转义\\

    使用str.split("[",15)时,出现Exception in thread "main" java.util.regex.PatternSyntaxE ...

  4. Exception in thread "main" java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for topic_test_1219-2: 30010 ms has passed since batch creatio

    代码如下 public static void producer1() throws ExecutionException, InterruptedException { Properties pro ...

  5. Exception in thread "main" java.util.InputMismatchException

    今天写代码来了一个异常 /** * 需求分析:根据输入的天数是否是周六或是周日, * 并且天气的温度大于28摄氏度,则外出游泳,否则钓鱼 * @author chenyanlong * 日期:2017 ...

  6. WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable Exception in thread "main" java.io.IOException: No FileSystem for sc F

    1.执行脚本程序报如下所示的错误: [hadoop@slaver1 script_hadoop]$ hadoop jar web_click_mr_hive.jar com.bie.hive.mr.C ...

  7. Exception in thread "main" java.lang.StackOverflowError at java.util.ArrayList$SubList.rangeCheckForAdd(Unknown Source)

    Exception in thread "main" java.lang.StackOverflowError at java.util.ArrayList$SubList.ran ...

  8. unit测试出现异常:Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.commons.util

    在进行单元测试时,测试出现异常 Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform ...

  9. Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/util/POILogFactory

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/util/POILogFacto ...

随机推荐

  1. 【bzoj4152】【The Captain】最短路(堆优化)(浅尝ACM-B)

    [pixiv] https://www.pixiv.net/member_illust.php?mode=medium&illust_id=62834538 Description 给定平面上 ...

  2. iOS 代理 重定向消息 forwardInvocation

    今天简单研究一下iOS的重定向消息forwardInvocation: 首先看看Invocation类: @interface NSInvocation : NSObject { @private _ ...

  3. Springboot集成BeanValidation扩展一:错误提示信息加公共模板

    Bean Validator扩展 1.需求 ​ 在使用validator时,有个需求就是公用错误提示信息,什么意思? 举个例子: ​ @NotEmpty非空判断,在资源文件中我不想每个非空判断都写”不 ...

  4. JAVA常见算法题(二十三)

    package com.xiaowu.demo; /** * 给一个不多于5位的正整数,要求:①求它是几位数:②逆序打印出各位数字. * * * @author WQ * */ public clas ...

  5. JAVA常见算法题(四)

    package com.xiaowu.demo; /** * 将一个正整数分解质因数.例如:输入90,打印出90=2*3*3*5. * * * @author WQ * */ public class ...

  6. 批处理学习:for语句详解

    大纲 一 前言 二 for语句的基本用法 三 for /f (delims.tokens.skip.eol.userbackq.变量延迟) 四 for /r (递归遍历) 五 for /d (遍历目录 ...

  7. Linux alias理解及设置

    1.alias简介 Linux alias 是命令的一种别称,输入 alias 可以看到像下面这样的结果: alias l.='ls -d .* --color=auto' alias ll='ls ...

  8. 【Java】String和Date、Timestamp之间的转换

    首先,定义一个Format的日期格式: SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 一.S ...

  9. 斯坦福《机器学习》Lesson5感想———1、成学习算法

    在前面几课里的学习算法的思路都是给定数据集以后.确定基于此数据集的最佳如果H函数,通过学习算法确定最佳如果H的各个參数,然后通过最佳如果函数H得出新的数据集的结果.在这一课里介绍了一种新的思路,它的核 ...

  10. PICT工具安装使用

    前言:PICT工具在微软公司出品一款成对组合的命令行生成工具.PICT 可有效地按照两两测试Pairwise的原理,进行测试用例设计.在使用PICT时,需要输入与测试用例相关的所有参数,以达到全面覆盖 ...