package Devmanuals.com; import java.util.List; import java.util.ArrayList; import java.util.Iterator; public class IteratorRemove { public static void main(String[] args) { ArrayList al = new ArrayList(); for (int i = 10; i <= 20; i++) al.add(i); Iterator itr = al.iterator(); System.out.println("Is list contain more elements ? " + itr.hasNext()); System.out.println("Old list = "+al); while (itr.hasNext()) { Integer i1 = (Integer) itr.next(); if (i1 == 15) itr.remove(); } System.out.println("After removing the last called "); System.out.println("element by iterator, then list = " + al); } }