Here you can find the source of gotoIndex(ListIterator> iterator, int index)
public static void gotoIndex(ListIterator<?> iterator, int index)
//package com.java2s; //License from project: Open Source License import java.util.ListIterator; public class Main { public static void gotoIndex(ListIterator<?> iterator, int index) { int steps = index - iterator.nextIndex(); if (steps < 0) { steps = 0 - steps;//from w w w . ja v a 2s . c om for (int i = 0; i < steps; i++) { iterator.previous(); } } else { for (int i = 0; i < steps; i++) { iterator.next(); } } } }