Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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;
        Iterator<T> it = c.iterator();
        while (it.hasNext() && ret == null) {
            T t = it.next();
            if (t != null)
                ret = t;
        }
        return ret;
    }
}