- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
<分区>
我有非常简单的代码:
List<String> list = new ArrayList<String>();
String a = "a";
String b = "b";
String c = "c";
String d = "d";
list.add(a);
list.add(b);
list.add(c);
List<String> backedList = list.subList(0, 2);
list.add(0, d);
System.out.println("2b: " + backedList);
我通过 list.add(0, d) 得到了 ConcurrentModificationException 异常。所以一般来说,是因为sublist()。我很困惑,因为在 sublist() 的情况下,文档说:
The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa.
你能解释一下问题在哪里吗?
这个问题在这里已经有了答案: Why is a ConcurrentModificationException thrown and how to debug it (8 个答案) 关闭 3 年前。
这个问题已经有答案了: Concurrent Modification exception [duplicate] (9 个回答) 已关闭 8 年前。 在oldSet.removeAll(已删除);抛
这个问题在这里已经有了答案: Concurrent Modification exception [duplicate] (9 个回答) 关闭 9 年前。 我的程序抛出 ConcurrentModi
我有以下结构: public class Object1{ private HashMap myMap; ... public void cancelItem(Item o)
在本例中使用 list.remove((Object)93) 会导致 ConcurrentModificationException: List list = new ArrayList<>(); l
更新应用程序后,我收到来自 Firebase 的错误几乎在所有 Activity 中。 Fatal Exception: java.lang.RuntimeException: Unable to s
我有大量的东西,一个重复迭代它们的线程,以及一个偶尔删除或添加单个东西的单独线程。事物在同步链表中: private List things = Collections.synchronizedLis
在 DTO 中我有 public class ProductTypesDto extends BaseDto { private List colors = new ArrayList<>();
我正在创建一个 Swing 应用程序来制作游戏。它在屏幕外的随机位置创建图像,当它们离开屏幕时我想将它们删除。请看一下代码片段: public void checkTrolls(){ //CAUSES
我在向 Android 表插入数据时遇到问题。这是我的 Dao 函数: @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(frei
我有一个 Grails (2.4.3) 应用程序,它使用 PersistenceListener 来监听 GORM 事件。 PersistenceListener 工作正常。在 PreUpdate 事
基于 Spring Boot、spring-data-jpa 的大型 REST Web 应用程序。我有 PersonEntity ,它与 ParentEntity 具有 ManyToOne 关系。关系
我有一个作业要编写一个 Java 程序,该程序将读取上下文无关语法并返回所有非终结符的 FirstSet。我使用 FirstSet() 方法采用了递归方法: public static ArrayLi
我收到java.util.ConcurrentModificationException,但我不知道为什么。 在 Logcat 中,它指向此代码,但我没有看到任何可能导致 ConcurrentModi
我在以下情况下收到 ConcurrentModificationException 错误。线路发生这种情况的地方标有“ list = Collections.synchronizedList(them
自过去两个小时以来,我一直在尝试解决此异常..我得到了抛出异常的代码行..但没有找到解决方案..请帮助我发生错误@ mUsers.add(user);//在其他部分 private void read
我有以下代码: List list = getItems(); //where getItems() returns List do { list.add(ad
我得到ConcurrentModificationException当迭代 map 的内容时 for (String sourceKey : sMap.getContent().keySet(
代码是葡萄牙语的,对此我很抱歉。 我在这里读到另一个问题,因为我正在使用progSelecionada.remove(),所以抛出了异常,所以我更改为iterator.remove()但错误仍然存
我目前正在用 Java 编写多人游戏。我当前的代码(即出现错误)是这样的。 @Override public void onClose(WebSocket conn, int code, String
我是一名优秀的程序员,十分优秀!