Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

java
boolean

What is Boolean.logicalOr in Java?

abhilash

Overview

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 values

A 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

Method Signature

public static boolean logicalOr(boolean a, boolean b)

Parameters

boolean a - first operand.
boolean b - second operand.

Return values

Logical OR of the two operands.

Code

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));
    }
}

RELATED TAGS

java
boolean
RELATED COURSES

View all Courses

Keep Exploring