What are the logical operators in Java?
Logical operators include logical AND (&&), logical OR (||) and logical NOT (!). The first two are binary operators, and the latter one is a unary operator.
Java provides a "short-circuit" function for logical AND and logical OR, that is, when performing operations, the value of the expression on the left side of the operator is first calculated. If this value is used, the value of the entire expression can be obtained. Then the calculation of the expression on the right side of the operator is skipped, otherwise the expression on the right side of the operator is calculated and the value of the entire expression is obtained.
(Recommended video tutorial: java video)
Please see the picture below for specific examples:
Recommended tutorial :java introductory program
The above is the detailed content of What are the logical operators in java. For more information, please follow other related articles on the PHP Chinese website!