Java List.listIterator(int index)

Syntax

List.listIterator(int index) has the following syntax.

ListIterator < E > listIterator(int index)

Example

In the following code shows how to use List.listIterator(int index) method.


//www. j ava 2s  .  c  o m
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

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(1);
    while (iter.hasNext()) {
      System.out.println(iter.next());
    }

  }
}

The code above generates the following result.