The logicalOr
method is a static method of the Boolean
class in Java. The method computes the logical OR
operation on two Boolean operands/values.
The logical OR
operator is represented as ||
in Java. This method was introduced in Java 8.
OR
operation on Boolean valuesA Boolean data type can take 2 values, i.e. true
and false
. The result of the logical OR
operation between the different combinations of the two Boolean data types is as follows.
First Operand | Second Operand | First Operand || Second Operand |
---|---|---|
true | true | true |
true | false | true |
false | true | true |
false | false | false |
public static boolean logicalOr(boolean a, boolean b)
boolean a
- first operand.
boolean b
- second operand.
Logical OR
of the two operands.
public class Main {public static void main(String[] args) {System.out.println("true || true = " + Boolean.logicalOr(true, true));System.out.println("true || false = " + Boolean.logicalOr(true, false));System.out.println("false || true = " + Boolean.logicalOr(false, true));System.out.println("false || false = " + Boolean.logicalOr(false, false));}}