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