Java Lambda - Predicate test example








Predicate test evaluates this predicate on the given argument.

Syntax

test has the following syntax.

boolean test(T t)

Example

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("java2s.com "));
  }
}

The code above generates the following result.