I got error when removing one of the element in my list of (list of integers). I use iterator to remove that element
Here is my code:
List<List<Integer>> list = new ArrayList<List<Integer>>();
....
....
Iterator<List<Integer>> myListIterator = list.iterator();
int ct1 = 0;
while (myListIterator.hasNext()) {
    List<Integer> val = myListIterator.next(); // here is the error 
    if(ct1 == val.get(0))
        list.remove(val);
    ct1++;
}
And I got this error message:
Exception in thread "main" java.util.ConcurrentModificationException
    at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
    at java.util.ArrayList$Itr.next(Unknown Source)
Does anyone know what's wrong with my code? Thank you guys!
 
    