Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorListIteratorExample3 { public static void main(String arg[]) { //Create an empty vector Vector
vec = new Vector<>(); //Add elements to the vector vec.add(1); vec.add(2); vec.add(3); vec.add(4); vec.add(5); //Get ListIterator object using listIterator() method ListIterator
li = vec.listIterator(); System.out.println("Iterate elements are: "); //Iterate elements to the vector while(li.hasNext()) { System.out.println(li.next()); } } }
Output