HTML & JS
// Java program to demonstrate working of
// Iterator.remove() on an integer arraylist
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;

public class GFG
{
    public static void main(String[] args)
    {
        List<Integer> al = new ArrayList<Integer>();
        al.add(1);
        al.add(2);        
        al.add(10);
        al.add(20);
        al.add(30);

        // Remove elements smaller than 10 using
        // Iterator.remove()
        for (Integer x : al)
        {
            if (x >= 10)
                al.remove(new Integer(x));
        }

        System.out.println("Modified ArrayList : "
                                           + al);
    }
}

Generated URL:

Runtime Errors:

Exception in thread "main" java.util.ConcurrentModificationException
	at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909)
	at java.util.ArrayList$Itr.next(ArrayList.java:859)
	at GFG.main(GFG.java:20)

Output:

No Output
Report Bug