What are the logical operators in Java?

Java 8Object Oriented ProgrammingProgramming

A logical operator acts on two boolean values and returns another boolean value. The following table lists the logical operators.

 Assume boolean variable a holds true and variable B holds false, then:

Operator
Description
Example
&& (logical and)
Called Logical AND operator. If both the operands are non-zero, then the condition becomes true.
(A && B) is false
|| (logical or)
Called Logical OR Operator. If any of the two operands are non-zero, then the condition becomes true.
(A || B) is true
! (logical not)
Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false.
!(A && B) is true
raja
Published on 12-Jan-2018 14:52:52
Advertisements