fork(3) download
  1. import java.util.List;
  2. import java.util.ArrayList;
  3. import java.util.Iterator;
  4.  
  5. public class Main {
  6. public static void main(String args[]) {
  7.  
  8. List<String> myList = new ArrayList<String>();
  9. myList.add("January");
  10. myList.add("February");
  11. myList.add("March");
  12. myList.add("April");
  13.  
  14. Iterator<String> it = myList.iterator();
  15. while(it.hasNext())
  16. {
  17. String item = it.next();
  18. System.out.println("Checking: " + item);
  19. if("February".equals(item))
  20. {
  21. myList.remove(item);
  22. }
  23. }
  24.  
  25. for (String item : myList)
  26. {
  27. System.out.println(item);
  28. }
  29.  
  30. }
  31. }
Runtime error #stdin #stdout 0.06s 380224KB
stdin
Standard input is empty
stdout
Checking: January
Checking: February