Here you can find the source of getIndexInIterator(Iterator
public static <T> T getIndexInIterator(Iterator<T> iterator, int index)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; public class Main { public static <T> T getIndexInIterator(Iterator<T> iterator, int index) { for (int i = 0; iterator.hasNext(); i++) { T current = iterator.next(); if (i == index) { return current; }/*from w w w .j a v a2 s . c om*/ } return null; } }