ListIterator: nextIndex() : ListIterator « java.util « Java by API






ListIterator: nextIndex()

 
import java.util.ArrayList;
import java.util.ListIterator;

public class Main {
  public static void main(String[] args) {
    ArrayList<String> aList = new ArrayList<String>();

    aList.add("1");
    aList.add("2");
    aList.add("3");
    aList.add("4");
    aList.add("5");

    ListIterator<String> listIterator = aList.listIterator();
    System.out.println("Previous: " + listIterator.previousIndex());
    System.out.println("Next: " + listIterator.nextIndex());

    // advance current position by one using next method
    listIterator.next();
    System.out.println("Previous: " + listIterator.previousIndex());
    System.out.println("Next: " + listIterator.nextIndex());
  }
}

   
  








Related examples in the same category

1.ListIterator: add(T e)
2.ListIterator: hasNext()
3.ListIterator: next()
4.ListIterator: hasPrevious()
5.ListIterator: previous()
6.ListIterator: previousIndex()
7.ListIterator: remove()
8.ListIterator: set(T e)