Share on Google+Share on Google+

Java Vector Iterator

In this segment of tutorial we will learn about the Vector class and its use with the Iterator interface.Then We will create an example to print the content of the a Vector.

  • Java Vector Iterator is a Collection class. It has similar functionality as of the Array.
  • Its size is variable
  • 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 Example
import java.util.Iterator;
import java.util.Vector;

public class vector1 {

	public static void main(String[] args) {
		Vector v = new Vector();
		String tree[] = { "olive", "oak", "grass", "mango" };
		for (String s : tree) {
		Iterator it = v.iterator();
		for (; it.hasNext();)


olive oak grass mango


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