In this tutorial we will learn how to use the Iterator interface as Array. We will create an example print the multiple ArrayList at a time using the Iterator.
In this tutorial we will learn how to use the Iterator interface as Array. We will create an example print the multiple ArrayList at a time using the Iterator.
import java.util.ArrayList; import java.util.Iterator; public class javafor { public static void main(String[] args) { ArrayList list = new ArrayList(); list.add(new Integer(111)); list.add(222); list.add(new Integer(333)); list.add(444); Iterator it = list.iterator(); for (; it.hasNext();) { System.out.println(it.next()); } } }
Output
111 222 333 444