Java Collection First getFirstNonNull(Collection c)

Here you can find the source of getFirstNonNull(Collection c)

Description

get First Non Null

License

Open Source License

Declaration

public static <T> T getFirstNonNull(Collection<T> c) 

Method Source Code

//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;
    }
}

Related

  1. getFirstItem(Collection c)
  2. getFirstItem(Collection collection)
  3. getFirstItem(Collection c)
  4. getFirstItemInCollection(Collection collection)
  5. getFirstN(Collection objects, int n)
  6. getFirstNotNullValue(final Collection collection)
  7. getFirstOrNull(final Collection collection)
  8. getFirstSortedItem( Collection items, T defaultValue)
  9. getUnionSize(Collection firstCollection, Collection secondCollection)