LongPredicate and example

Description

LongPredicate and returns a composed predicate that represents a short-circuiting logical AND of this predicate and another.

Syntax

and has the following syntax.


default LongPredicate and(LongPredicate other)

Example

The following example shows how to use and.


import java.util.function.LongPredicate;
/*from w  w  w.  ja v  a 2s  . co m*/
public class Main {

  public static void main(String[] args) {
    LongPredicate i = (l) -> l > 0;
    LongPredicate j = (l) -> l == 0;
    
    System.out.println(i.and(j).test(Long.MAX_VALUE));
  }
}

The code above generates the following result.