ConcurrentModificationException: .add() vs .addAll()
Why does the following occur? Shouldn't both work? List<String> items = data; for( String id : items ) { List<String> otherItems = otherData; // 1. addAll() //Causes ConcurrentModificationException items.addAll(otherItems); // 2. .add() //Doesn't cause exceptions for( String otherId : otherItems ) { items.add(otherId); } } Is it because add() adds to the collection Items, but addAll() creates a new collection thus modifying Items to be a different instance of List? Edit items and otherItems are of concrete type ArrayList<String> . Neither operation is proper, since it modifies the collection