Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import com.google.common.base.Predicate;

import java.util.Collection;

import java.util.Iterator;

public class Main {
    public static <T> T find(Collection<T> collection, Predicate<T> whatToFind) {
        for (Iterator<T> iter = collection.iterator(); iter.hasNext();) {
            T item = iter.next();
            if (whatToFind.apply(item)) {
                return item;
            }
        }
        return null;
    }
}