import java.util.ArrayList;
import java.util.Iterator;
public class Foo {
    public static void main(String[] args) {
        ArrayList<Integer> lista = new ArrayList<Integer>();
        for (int i = 0; i < 10; i++) {
            lista.add(i + 1);
            System.out.println(lista);
        }
        Iterator<Integer> it = lista.iterator();
        try {
            while (it.hasNext()) {
                // it.next();
                it.remove();
                System.out.println(lista);
            }
        } catch (Exception ex) {
            System.out.println("Exception!");
            System.out.println(ex.getMessage());
            System.out.flush();
        }
    } 
}
