Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorIteratorExample2 { public static void main(String arg[]) { //Create an empty Vector Vector < Integer > in = new Vector < > (); //Add elements in the vector in.add(100); in.add(200); in.add(300); in.add(400); //Obtain an Iterator Iterator
itr = in.iterator(); while(itr.hasNext()){ System.out.println(itr.next()); } } }
Output