Last Updated: 28 May, 2022
Operators are special symbols that perform the specified operations. Each operator is responsible to perform some specific operation on variables or values and return a result. The operators are classified and listed according to precedence order.
Java supports the following types of operators:
Logical operators are used to checking an expression or combination of expressions is true or false. This operator performs logical && (AND), || (OR) and ! (NOT) operations.
Just for understanding the below table let's assume X=10, Y=20
Operator | Operator Name | Description | Example | Output |
---|---|---|---|---|
&& | Logical AND | True if both the expressions are true otherwise false | ((X > 20) && (Y > 40)) |
false |
|| | Logical OR | True if either expression is true otherwise false | ((X > 20) || (Y < 40)) |
true |
! | Logical NOT | True if expression is false otherwise false | !((X > 20) && (Y > 40)) |
true |
Example: Logical Operators in Java
Output
true
false
true
false
true
false
That's all guys, hope this Java article is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com