---
title: "Discussion on \"foreach 中无法删除和添加元素\" | Hashnode"
description: "Discussion on \"foreach 中无法删除和添加元素\". fail-fast 是一种通用的系统设计思想，一旦检测到可能会发生错误，就立马抛出异常\nthrow new ConcurrentModificationException();\n\n抛出 ConcurrentModificationException 异常之后不需要捕获，直接中止程序\n示例\nclass TEST {\n    public static void main(String[] args) {\n        ArrayList<Integer> integers = new Array..."
url: "https://hashnode.com/posts/foreach/64b742c8e07b1e8bfec7fc48"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [foreach 中无法删除和添加元素](https://zhengsongling.com/foreach?utm_source=hashnode&utm_medium=feed)

fail-fast 是一种通用的系统设计思想，一旦检测到可能会发生错误，就立马抛出异常 throw new ConcurrentModificationException(); 抛出 ConcurrentModificationException 异常之后不需要捕获，直接中止程序 示例 class TEST { public static void main(String\[\] args) { ArrayList<Integer> integers = new Array...

Jul 19, 2023 · 3 min read · zhengsongling.com  
Read the article

-   [#java](https://hashnode.com/tag/java)

## Written by

[zhengsl](https://hashnode.com/@zhengsl)

@zhengsl

  
[View profile](https://hashnode.com/@zhengsl)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
