Check if a value is in Array by Predicate - Android java.lang

Android examples for java.lang:array

Description

Check if a value is in Array by Predicate

Demo Code


//package com.book2s;

import java.util.Arrays;

import java.util.List;

import java.util.function.Predicate;

public class Main {
    public static <T> boolean contains(T[] toFilter, Predicate<T> predicate) {
        return contains((List<T>) Arrays.asList(toFilter), predicate);
    }/*from   w w  w.  ja v a2  s.co  m*/

    public static <T> boolean contains(List<T> toFilter,
            Predicate<T> predicate) {
        return toFilter.stream().anyMatch(predicate);
    }
}

Related Tutorials