fork download
  1. import java.util.*;
  2.  
  3. class Ideone {
  4. public static void main (String[] args) {
  5. List<String> list = new ArrayList<String>();
  6. list.add("a");
  7. list.add("b");
  8. list.add("c");
  9. for (int i = 0; i < list.size(); i++) {
  10. System.out.println("Passo " + i + " Antes => " + list.get(i));
  11. list.remove(list.get(i));
  12. System.out.println("Passo " + i + " Depois => " + list.get(i));
  13. }
  14. }
  15. }
  16.  
  17. //https://pt.stackoverflow.com/q/341518/101
Runtime error #stdin #stdout #stderr 0.04s 2184192KB
stdin
Standard input is empty
stdout
Passo 0 Antes => a
Passo 0 Depois => b
Passo 1 Antes => c
stderr
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
	at java.util.ArrayList.get(ArrayList.java:429)
	at Ideone.main(Main.java:12)