Java Lambda - LongPredicate and example

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


and has the following syntax.

default LongPredicate and(LongPredicate other)


The following example shows how to use and.

import java.util.function.LongPredicate;
/*w  w  w  .ja va  2  s  .c o  m*/
public class Main {

  public static void main(String[] args) {
    LongPredicate i = (l) -> l > 0;
    LongPredicate j = (l) -> l == 0;

The code above generates the following result.