-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtutorial_16.java
38 lines (30 loc) · 1.18 KB
/
tutorial_16.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import static java.lang.System.out;
class Driver {
public static void main(String[] args) {
int a = 3;
int b = 5;
int c = 3;
// all of them have to be true in order to get back true
out.println("Logical and ( && )");
out.println( a == c && a < b );
out.println( a <= c && b == 5 && b < c );
// only one of them has to be true to get back true
out.println("Logical or ( || )");
out.println( a < c || a < b );
out.println( a != 3 || c > b || a == 4 );
// one has to be true the other has to be false to get back true
out.println("Bitwise exclusive or ( ^ )");
out.println( a == c ^ a == b );
out.println( a != 3 ^ c > b );
out.println( a == 3 ^ b == 5 );
// combine them together
out.println("Using them together");
out.println( a == c && a < b || a == 3 );
out.println( a == c && a >= b || a == 3 );
// reverse the check
out.println("Logical not ( ! )");
out.println( a == c && a < b || a == 3 );
out.println( !(a == c) );
out.println( !(a > b) );
}
}