Java tutorial
//package com.java2s; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; public class Main { public static <T> List<T> filter(Collection<T> toFilter, Predicate<T> predicate) { return toFilter.stream().filter(predicate).collect(Collectors.toList()); } public static <T> List<T> filter(T[] toFilter, Predicate<T> predicate) { return filter((List<T>) Arrays.asList(toFilter), predicate); } }