filter value from Collection by Predicate - Android java.util

Android examples for java.util:Collection Filter

Description

filter value from Collection by Predicate

Demo Code


//package com.book2s;

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());
    }//from   w w w .j  a  va2s  . c om
}

Related Tutorials