Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorListIteratorExample2 { public static void main(String arg[]) { //Create an empty vector Vector
vec = new Vector<>(); //Add elements to the vector vec.add("Orange"); vec.add("Mango"); vec.add("Banana"); vec.add("Apple"); //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