Share on Google+Share on Google+

Java List Iterator

In this tutorial we will see about the iterator interface and its functionality.We will create an example for the Iterator

  • Java List Iterator is an interface in the collection framework
  • It traverses through all the elements of the collection.
  • It works like enumeration.
  • It has methods hasNext() and next().

Example of Java List Iterator

import java.util.*;

public class iterator {

	public static void main(String[] args) {
		List list = new ArrayList();
		for (int i = 0; i < 5; i++) {
			list.add(new Random().nextInt(100));
		Iterator i = list.iterator();
		while (i.hasNext()) {
			System.out.print( + "\t");


39 73 87 49 1


Posted on: November 3, 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.