Predicate example

Description

Predicate represents a predicate, which is boolean-valued function, of one argument.

Example

The following example shows how to use Predicate.


import java.util.function.Predicate;
//from w  w w.  j  a v  a  2  s  .c  om
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.