Home Tutorial Java Iterator Vector Iterator Java Example


Share on Google+Share on Google+
Vector Iterator Java Example
Posted on: November 3, 2009 at 12:00 AM
This segment of tutorial illustrates about the Vector class and its use with the Iterator interface.We will create an example to print the content of the a Vector.

  • Vector is a collection class.It works similar to the Array.
  • It has growable array.Its size may increase or decrease.
  • It has iterator() method.So Iterator interface can traverse all its elements.

Java Vector Iterator with Example
import java.util.Iterator;
import java.util.Vector;

public class vector {

	public static void main(String[] args) {
		Vector v = new Vector();
		String city[] = { "delhi", "hongkong", "dubai", "sanghai" };
		for (String s : city) {
		Iterator it = v.iterator();
		for (; it.hasNext();)


delhi hongkong dubai sanghai

Related Tags for Vector Iterator Java Example:

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