Home Tutorial Java Iterator Iterator Java Tutorial


Share on Google+Share on Google+
Iterator Java Tutorial
Posted on: November 4, 2009 at 12:00 AM
In this java tutorial we will see about the iterator interface and its functionality. We will create an example for the Iterator

  • Java 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().
  • List, Set interface has iterator() methods .

Example of Java Iterator
import java.util.*;

public class iterator1 {
	public static void main(String[] args) {
		List list = new ArrayList();
		int ar[] = { 11, 22, 33, 44, 55 };
		for (int i = 0; i < ar.length; i++) {
		Iterator i = list.iterator();
		while (i.hasNext()) {
			System.out.print(i.next() + "\t");


11 22 33 44 55

Related Tags for Iterator Java 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.

Posted on: November 4, 2009

Recommend the tutorial

Advertisements Advertisements