Android examples for java.util:Collection Filter
filter Collection by android Predicate
import com.android.internal.util.Predicate; import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main{ public static <E> List<E> filter(Collection<E> src, Predicate<E> p) { final ArrayList<E> res = new ArrayList<>(); for (E elem : src) { if (p.apply(elem)) { res.add(elem);/* w w w . j a v a 2s . c o m*/ } } return res; } }