Here you can find the source of getFirstNonNull(Collection
public static <T> T getFirstNonNull(Collection<T> c)
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.util.Collection; import java.util.Iterator; public class Main { public static <T> T getFirstNonNull(Collection<T> c) { T ret = null;/*from w w w . ja va 2 s. c om*/ Iterator<T> it = c.iterator(); while (it.hasNext() && ret == null) { T t = it.next(); if (t != null) ret = t; } return ret; } }