Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorListIteratorExample4 { 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); //Get ListIterator object using listIterator() method along with returned index list ListIterator
li = vec.listIterator(25); System.out.println("Iterate elements are: "); //Iterate elements to the vector while(li.hasNext()) { System.out.println(li.next()); } } }
Output