Here you can find the source of firstFrom(Collection
public static <T> T firstFrom(Collection<T> coll)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Map; public class Main { public static <T> T firstFrom(Collection<T> coll) { if (isEmpty(coll)) return null; return coll.iterator().next(); }//from ww w . j a v a 2 s . c o m public static boolean isEmpty(Object o) { return o == null; } public static boolean isEmpty(Collection<?> col) { return col == null || col.size() == 0; } public static boolean isEmpty(String str) { return str == null || str.length() == 0; } public static boolean isEmpty(Map<?, ?> map) { return map == null || map.size() == 0; } public static boolean isEmpty(Object[] arr) { return arr == null || arr.length == 0; } }