2
2
.
.
1
1
.
.
1
1
1
1
O
O
p
p
e
e
r
r
a
a
t
t
o
o
r
r
s
s
-
-
L
L
o
o
g
g
i
i
c
c
a
a
l
l
I
I
n
n
f
f
o
o
Logical operators are used to combine boolean values that can be only TRUE or FALSE.
This way they provide a method to direct program flow depending on the outcome.
Logical
//TEST VARIABLES.
char left = 65;
long right = 70;
//LOGICAL OPERATORS.
if ( left> 50 && right==70 ) { System.out.println("Both are true" ); } // AND
if ( left> 50 AND right==70 ) { System.out.println("Both are true " ); } // AND
if ( left!=4 || right> 90 ) { System.out.println("At least one is true" ); } // OR
if ( left!=4 OR right> 90 ) { System.out.println("At least one is true " ); } // OR
if ( left!=4 XOR right> 90 ) { System.out.println("Only one is true ); } // XOR
if ( ! (left==80)) { System.out.println("left is NOT equal to 80" ); } // NOT
if ( NOT (left==80)) { System.out.println("left is NOT equal to 80" ); } // NOT