Java Lambda - Predicate test example

Predicate test evaluates this predicate on the given argument.


test has the following syntax.

boolean test(T t)


The following example shows how to use test.

import java.util.function.Predicate;
//from  w w w.jav  a 2  s.  c  o  m
public class Main {

  public static void main(String[] args) {
    Predicate<String> i  = (s)-> s.length() > 5;
    System.out.println(i.test(" "));

The code above generates the following result.