listIterator(): This method is available in java.util.Vector class of Java.
Syntax:
ListIterator<K> java.util.Vector.listIterator()
This method returns a list iterator over the elements in this list.
Parameters: NA
Returns: a list iterator over the elements in this list.
Exceptions: NA
Approach
Java
import java.util.ListIterator;import java.util.Vector;public class VectorlistIterator {public static void main(String[] args) {Vector<String> vector = new Vector<>();vector.add("Hello");vector.add("Java");vector.add("C++");vector.add("Program");ListIterator<String> listIterator =vector.listIterator();listIterator.forEachRemaining((n ->System.out.print(n + " ")));}}
Output:
Hello Java C++ Program
No comments:
Post a Comment