- The difference between && and &
1, the final result is the same.
2, && has short-circuit effect. The left side is false and the right side is not executed.
Class YSF {
public static void Main (string[] args) {
int a = 10;
int B = 20;
int c = 30;
System.out.println (A < b && B < c); //true && true = True
System.out.println (A < b && B > C); //true && false = False
System.out.println (A > B && b < c); //false && true = False
System.out.println (A > B && b > C); //false && false = False
}
}
1, The final result is the same
2, | | Short circuit effect, true on left, not on right
class YSF {
Public static void Main (string[] args) {
int a = ten;
int b =;
int c =;
System.out.println (A < b | | b < c); //true && true = True
System.out.println (A < b | | b > C); //true && false = true
System.out.println (a > B | | b < c); //false && true = true
System.out.println (a > B | | b > C); //false && false = False
}
}
&: There are 0 0
| : There are 1 1
^: same 0, different 1
~: Bitwise REVERSE
class YSF {
Public static void Main (string[] args) {
int a = ten;
int b =;
int c =;
System.out.println (6 & 3); //2
System.out.println (6 | 3); //7
System.out.println (6 ^ 3); //5
System.out.println (); //-7
}
}
Java_ Study the next day (iv) [logical operator (&&) (| | ) (^) (~)]