-
Notifications
You must be signed in to change notification settings - Fork 1
/
06_AssignmentOperator.java
65 lines (53 loc) · 1.65 KB
/
06_AssignmentOperator.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
public class AssignmentOperator {
public static void main(String[] args) {
// 1. Assignment operator (=)
int a = 20;
System.out.println(a);
// 2. Addition assignment operator (+=)
int b = 20;
b += 10;
System.out.println(b);
// 3. Subtraction assignment operator (-=)
int c = 20;
c -= 10;
System.out.println(c);
// 4. Multiplication assignment operator (*=)
int d = 20;
d *= 10;
System.out.println(d);
// 5. Division assignment operator (/=)
int e = 20;
e /= 10;
System.out.println(e);
// 6. Remainder assignment operator (%=)
int f = 20;
f %= 10;
System.out.println(f);
// 7. Logical NOT assignment operator (!=)
System.out.println(true != false);
// 8. Bitwise AND assignment operator (&=)
int k = 2;
k &= 2;
System.out.println(k);
// 9. Bitwise OR assignment operator (|=)
int l = 2;
l |= 2;
System.out.println(l);
// 10. Bitwise XOR assignment operator (^=)
int m = 2;
m ^= 2;
System.out.println(m);
// 11. Left shift assignment operator (<<=)
int n = 2;
n <<= 2;
System.out.println(n);
// 12. Right shift assignment operator (>>=)
int o = 2;
o >>= 2;
System.out.println(o);
//13. Unsigned right shift assignment operator (>>>=)
int p = 2;
o >>>= 2;
System.out.println(p);
}
}