The logic of logical operators in the Java programming language

The logic of logical operators in the Java programming language

Insert picture description here

The difference between logical AND and short-circuit and:

  • Logical operators are used to connect Boolean expressions. They cannot be written as 3<x<6 in Java, but should be written as x>3 & x<6.
    The difference between "&" and "&&": When
    single &, the left side is true or false, and the right side is operated;
    when double &, if the left side is true, the right side participates in the operation, if the left side is false, then the right side does not participate in the operation.
  • The difference between "|" and "||" is the same, || means: when the left side is true, the right side does not participate in the operation.
    The difference between XOR (^) and OR (|) is that when both left and right are true, the result is false.
    Understanding: XOR, the pursuit is "exclusive"!

Guess you like

Origin blog.csdn.net/DAurora/article/details/109011840