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 (String i: list) {
  10. System.out.println("Antes => " + i);
  11. if (i == "b") list.remove(i);
  12. System.out.println("Depois => " + i);
  13. }
  14. }
  15. }
  16.  
  17. //https://pt.stackoverflow.com/q/341518/101
Success #stdin #stdout 0.04s 2184192KB
stdin
Standard input is empty
stdout
Antes => a
Depois => a
Antes => b
Depois => b