1import java.util.ArrayList;
2import java.util.Iterator;
3public class ArrayListIteratorMethodExample
4{
5 public static void main(String[] args)
6 {
7 ArrayList<String> fruits = new ArrayList<String>(7);
8 fruits.add("banana");
9 fruits.add("mango");
10 fruits.add("apple");
11 fruits.add("watermelon");
12 fruits.add("pineapple");
13 fruits.add("orange");
14 fruits.add("plum");
15 Iterator<String> iterate;
16 iterate = fruits.iterator();
17 System.out.println("Fruits in ArrayList are: ");
18 while(iterate.hasNext())
19 {
20 System.out.println(iterate.next());
21 }
22 }
23}