Here you can find the source of getByIndex(Iterable
public static <T> T getByIndex(Iterable<T> iterable, int index)
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.util.Iterator; public class Main { public static <T> T getByIndex(Iterable<T> iterable, int index) { T el = null;/*from w ww .jav a2 s. co m*/ Iterator<T> it = iterable.iterator(); for (int i = 0; it.hasNext(); i++) { T cur = it.next(); if (i == index) { el = cur; break; } } return el; } }