Logical Operators (AND && - OR || - NOT !) Boolean Expressions - Java programming tutorial
Coding River
Logical Operators (AND && - OR || - NOT !) Boolean Expressions - Java programming tutorial
Hi and welcome back to this channel This video is the continuation of the video on Relational operators, as I promised in that video, today we are going to talk about Logical or Boolean Operators Actually, Logical Operators allow you to combine multiple logical expressions
That means that Logical Operators will only take logical values as operands. An expression containing Logical Operators will only return boolean values as well
In Java there exists three logical operators, which are ! the Operator “not” && the operator “and” | | the operator “or”
The first operator is the operator NOT One thing to note about this operator is that, when put in front of a logical expression it reverses the value of that logical expression
The second operator is the operator AND This will return true if and only if the two logical values are true Otherwise, it will evaluate to false
The third operator is the operator OR This will return true if one of the two logical values is true Otherwise, it will evaluate to false That means that the only time it evaluates to false is when the two logical expressions are false
In very complex expressions that use both relational and logical operators, it is recommended to use parentheses in the expressions in order to clarify its meaning, because the order of precedence of these operators may lead to unexpected errors
That’s it for the Logical Operators. In the next video, we will talk about how to use if statement in a one-way selection
#codingriver #java #programming ... https://www.youtube.com/watch?v=gHnRYnd_yAg
10582819 Bytes