Java examples for Collection Framework:Vector
Iterate through elements Vector using Iterator
import java.util.Vector; import java.util.Iterator; public class Main { public static void main(String[] args) { Vector v = new Vector(); /*from www .ja v a2 s .c o m*/ v.add("1"); v.add("2"); v.add("3"); v.add("4"); v.add("5"); //get an Iterator object for Vector using iterator() method. Iterator itr = v.iterator(); //use hasNext() and next() methods of Iterator to iterate through the elements while(itr.hasNext()) System.out.println(itr.next()); } }