Java tutorial
//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; Iterator<T> it = iterable.iterator(); for (int i = 0; it.hasNext(); i++) { T cur = it.next(); if (i == index) { el = cur; break; } } return el; } }