Here you can find the source of first(Collection extends T> collection)
public static <T> T first(Collection<? extends T> collection)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { public static <T> T first(Collection<? extends T> collection) { final T notFound = null; return isEmpty(collection) ? notFound : collection.iterator().next(); }/* www . j a va2 s .c o m*/ public static <T> boolean isEmpty(Collection<? extends T> collection) { return size(collection) == 0; } public static <T> boolean isEmpty(T[] array) { return array == null || array.length == 0; } public static int size(Collection<?> collection) { return collection != null ? collection.size() : 0; } public static <T> int size(T[] array) { return array == null ? 0 : array.length; } }