- Basic usage of logical operators
Class Demo {
public static void Main (string[] args) {
&,|,^,!
int a = 10;
int B = 20;
int c = 30;
Logic with & and False if it encounters false
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
Logic | Or or encounters true if True
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
Logical xor ^ on both sides of the same false, the difference is true
System.out.println (A > b ^ B > c);//true ^ true = False
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
Logical Non! is equivalent to taking counter
SYSTEM.OUT.PRINTLN (! true);
SYSTEM.OUT.PRINTLN (!! true);
Java_ Study the next day (iii) [Logical operator (&) (|) (^) (! )]