Java List.listIterator()
Syntax
List.listIterator() has the following syntax.
ListIterator < E > listIterator()
Example
In the following code shows how to use List.listIterator() method.
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
/*w w w. j ava 2 s .co m*/
public class Main {
public static void main(String[] a) {
List<String> list = new LinkedList<String>();
list.add("A");
list.add("B");
list.add("C");
list.add("D");
ListIterator iter = list.listIterator();
while (iter.hasNext()) {
System.out.println(iter.next());
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »