Home Tutorial Java Iterator Java Generic Iterator


Share on Google+Share on Google+
Java Generic Iterator
Posted on: November 3, 2009 at 12:00 AM
In this section of tutorial we will learn how to use the Generics with the Iterator interface. We will create an example using Generics in Iterator and ArrayList

  • Java Generic Iterator is the new feature added to the jdk1.5.
  • It is used to generalize the Collection classes.
  • It makes the Collection class type safe.
  • It is used with classes, methods and interfaces.

Java Generics Iterator Example
import java.util.ArrayList;
import java.util.Iterator;

public class generic {

	public static void main(String[] args) {
		ArrayList list = new ArrayList();
		// list.add(2000);//gives error
		Iterator it = list.iterator();
		while (it.hasNext())


india china

Related Tags for Java Generic Iterator :

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 3, 2009

Recommend the tutorial

Advertisements Advertisements