-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperator.java
More file actions
108 lines (99 loc) · 3.12 KB
/
operator.java
File metadata and controls
108 lines (99 loc) · 3.12 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
public class operator {
public static void main(String[] args) {
// 1. Binary operators
/*
* int A = 10;
* int B = 30;
* System.out.println(A + B);
* System.out.println("sum = " + (A + B));
* System.out.println(A - B);
* System.out.println("sub = " + (A - B));
* System.out.println(A * B);
* System.out.println(" mul = " + (A * B));
* System.out.println(A / B);
* System.out.println(" div = " + (A + B));
* System.out.println(A % B);
* System.out.println("mod = " + (A % B));
*/
// unary operator(also two type (1) preincreent operator (2) postincrement )
/*
* int a = 8;
* // [preincrement ]
* // int b = ++a;
* // [postincrement ]
* // int b = a++;
* // System.out.println(a);
* // System.out.println(b);
* // [predicrement]
* // int b = --a;
* // [postdecrement]
* int b = a--;
* System.out.println(a);
* System.out.println(b);
*/
// relational operators (==,!=,>,<,>=,<=)
/*
* int a = 90;
* int b = 80;
* System.out.println(a == b);
* System.out.println(a != b);
* System.out.println(a > b);
* System.out.println(a < b);
* System.out.println(a >= b);
* System.out.println(a <= b);
*/
// logical operator(&&,||,!)
// int a = 4;
// int b = 5;
// AND operator
/*
* System.out.println((a < b) && (a < b));
* System.out.println((a < b) && (a > b));
* System.out.println((a > b) && (a < b));
* System.out.println((a > b) && (a > b));
*/
// OR operator
/*
* System.out.println((a < b) || (a < b));
* System.out.println((a < b) || (a > b));
* System.out.println((a > b) || (a < b));
* System.out.println((a > b) || (a > b));
*/
// NOT operator(it i used to change the condition such as (true to false) and
// (false to true))
/*
* System.out.println(a < b);
* System.out.println(!(a < b));
* System.out.println(a > b);
* System.out.println(!(a > b));
*/
// assignment operstor(=,+=,-=,*=,/=)
int a = 8;
// a = a + 5;
// int sum = a + b;
// System.out.println(sum);
// a += a;
// a += 2;
// System.out.println(a);
// 2.
// int b = a;
// System.out.println(b);
// 3.
// int sub = a - 6;
// System.out.println(sub);
// a -= a;
// a -= 2;
// System.out.println(a);
// 3.*=
// int mul = a * 4;
// a *= a;67890-=
// a *= 2;
// System.out.println(a);
// int div = a / 2;
// System.out.println(div);
// a /= a;
a /= 2;
System.out.println(a);
}
}
// thanks operator lecture complete