Exception in thread "main" java.util.ConcurrentModificationException

常常咱們要刪除集合中的某些元素。有些可能會這麼寫。 public void operate(List list){ for (Iterator it = list.iterator(); it.hasNext();) { String str = (String)it.next(); if (str.equals("chengang")){ list.remove(str); } } }     
相關文章
相關標籤/搜索