Java 8 Boolean.logicalOr method

Mainly those methods are there for your convenience and to make the code more readable by using the method references in lambdas/streams. Let’s look at an example:

Stream.of(/* .. some objects .. */)
      .map(/* some function that returns a boolean */)
      .reduce(Boolean::logicalOr);

trying to write this with a || b:

Stream.of(...)
      .map(...)
      .reduce((a, b) -> a || b); // logicalOr is actually using ||

not that readable, right?

As Sotirios Delimanolis stated in the comment, you may also want to have a look at the javadoc and follow @see BinaryOperator. Or have a look at the function package summary javadoc.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)