Share on Google+Share on Google+

Iterate java 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.

  • Iterator is an interface in the collection framework.
  • ArrayList is a collection class and implements the List Inteface.
  • All the elements of the ArrayList can be traversed by the Iterator.
  • Iterator has methods hasNext() and next().

Example of Java Arraylist Iterate

import java.util.*;

public class javaarray {
	public static void main(String[] args) {

		List list = new ArrayList();
		Iterator i = list.iterator();
		while (i.hasNext()) {
			System.out.print( + "\t");


aaaa bbbb cccc dddd


Posted on: November 2, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null