Here you can find the source of getAt(Collection
public static <T> T getAt(Collection<T> col, int index)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.Iterator; import java.util.List; public class Main { public static <T> T getAt(Collection<T> col, int index) { if (col instanceof List) return ((List<T>) col).get(index); int i;/*w ww .j a va 2 s.c o m*/ Iterator<T> it; for (i = 0, it = col.iterator(); i < index && it.hasNext(); it.next()) ; return it.hasNext() ? it.next() : null; } }