fork(2) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. List<String> last = new ArrayList<>();
  13. last.add("a");
  14. last.add("b");
  15. last.add("c");
  16. for(String i : last){
  17. System.out.println(i);
  18. last.remove(i);
  19. }
  20. System.out.println(last);
  21. }
  22. }
Runtime error #stdin #stdout #stderr 0.11s 320576KB
stdin
Standard input is empty
stdout
a
stderr
Exception in thread "main" java.util.ConcurrentModificationException
	at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
	at java.util.ArrayList$Itr.next(ArrayList.java:851)
	at Ideone.main(Main.java:16)