Here you can find the source of getFirst(Collection
private static <T> T getFirst(Collection<T> ts)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.Iterator; public class Main { private static <T> T getFirst(Collection<T> ts) { final Iterator<T> it = ts.iterator(); return it.hasNext() ? it.next() : null; }/*w ww. j a v a 2 s. c o m*/ }