Android examples for java.util:Iterable
filter Iterable by Predicate
import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; import android.support.annotation.NonNull; public class Main{ public static <T> List<T> filter(@NonNull Iterable<T> iterable, @NonNull Predicate<T> predicate) { List<T> result = new ArrayList<>(); for (T element : iterable) { if (predicate.test(element)) { result.add(element);/*from w w w . j av a2 s .com*/ } } return result; } }