Here you can find the source of firstNonNull(Collection
public static <E> E firstNonNull(Collection<E> collection)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static <E> E firstNonNull(Collection<E> collection) { return firstNonNull(collection, null); }/*from w w w . j a v a2s . co m*/ public static <E> E firstNonNull(Collection<E> collection, E defaultValue) { for (E element : collection) { if (element != null) { return element; } } return defaultValue; } }