0
 for (String check : partresult) {
        int count=checkDiff(check,endword);
        if (count < min) {
            min = count;
            Iterator itr = res.iterator();
            while(itr.hasNext()) {
                Object elem=itr.next();
                if (checkDiff(elem.toString(), endword) != min)
                    res.remove(elem);
            }
            res.add(check);
        }
    }

for this piece of code, I have java.util.ConcurrentModificationException in the res.remove(elem). I already used an iterator, so really do not know what is wrong, hope somebody could help. thanks

Boris the Spider
  • 59,842
  • 6
  • 106
  • 166
rockmerockme
  • 131
  • 3
  • 13
  • You're not removing the element with the iterator. Don't do this. You'll also want to search this site before asking questions that likely have been asked many times before, because often the you'll find the answer quickly that way. For example: [site search](http://stackoverflow.com/search?q=%5Bjava%5D+ConcurrentModificationException+arraylist+remove) – Hovercraft Full Of Eels Apr 18 '15 at 22:46
  • `"I already used an iterator"` -- but again you're not removing with the iterator. Again, review these many, many, many [similar questions](http://stackoverflow.com/search?q=%5Bjava%5D+ConcurrentModificationException+arraylist+remove). – Hovercraft Full Of Eels Apr 18 '15 at 22:49

0 Answers0