Hello guys, if you are struggling to solve Exception in thread "main" java.util.ConcurrentModificationException" error in Java and wondering why this error comes even if you are not using multiple threads then you have come to the right place. In this tutorial, I will tell you everything about this error like why it comes and how you can solve it. One of the common problems while removing elements from an ArrayList in Java is the ConcurrentModificationException. If you use classical for loop with the index or enhanced for loop and try to remove an element from the ArrayList using remove() method, you will get the ConcurrentModificationException but if you use Iterator's remove method or ListIterator's remove() method, then you won't get this error and be able to remove the element.
This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here