In this tutorial we will see how to use the iterator interface with ArrayList. We will create an example to display the contents of the ArrayList.
In this tutorial we will see how to use the iterator interface with ArrayList. We will create an example to display the contents of the ArrayList.
import java.util.*; public class javaarray { public static void main(String[] args) { Listlist = new ArrayList (); list.add("aaaa"); list.add("bbbb"); list.add("cccc"); list.add("dddd"); Iterator i = list.iterator(); while (i.hasNext()) { System.out.print(i.next() + "\t"); } } }
Output
aaaa bbbb cccc dddd