Share on Google+Share on Google+

Vector Iterator Java Example

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


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.


Advertisement null