Logical Operators In Java
Logical Operator ?
Logical operator allow a program to make a decision based on multiple conditions. Each operand is considered a condition that can be evaluated to a true or false value.
➦Then the value of the conditions is used to determine the overall value of the op1 operator op2 or !op1 grouping.
&& operator is used to determine whether both operands or conditions are true.
|| is used to determine whether either of the conditions is true.
! operator is used to convert true values to false and false values to true.
|&&||And operator. if both expressions evaluate to True, result is True. If either expression evaluates to False, result is False|
|||||Or operator. if either or both expressions evaluate to True, result is True|
|!||Not operator. Performs logical negation on an expression.|
a && b = false a || b = true !(a && b) = true
a & b=1 a | b=97 a ^ b= 96 ~a= -66 boool1 & bool2=true bool2 & bool3= true bool2 | bool3= true bool1 ^ bool2= false !bool1= false