This section we demonstrates the use of iterator in Java ArrayList
This section we demonstrates the use of iterator in Java ArrayList
import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class List_for_iterator { public static void main(String[] args) { char grade[]={'A','B','C','D','E'}; List list=new ArrayList(); for (char c:grade) { list.add(c); } Iterator it=null; for(it=list.iterator();it.hasNext();) { System.out.println(it.next()); } } } Output A B C D E