-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperators.java
69 lines (52 loc) · 1.86 KB
/
operators.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
66
67
68
69
public class operators {
public static void main(String args[]){
int a = 10;
int b = 5;
// // // 1.Arithmetic Operators :
// // -> Binary
int plusOperator = a + b ;
int minusOperator = a - b;
int multiplicationOperator = a * b;
int DivisionOperator = a / b;
int moduloOperator = a % b;
System.out.println(plusOperator);
System.out.println(minusOperator);
System.out.println(multiplicationOperator);
System.out.println(DivisionOperator);
System.out.println("remainder " + moduloOperator);
// // -> Unary
a++;
b--;
--a;
++b;
// // // -> Ternary
int Great = (a>b) ? a : b ;
System.out.println(Great);
String val = (a%2 == 0)? "Even" : "odd" ;
System.out.println(val);
// // // 2. Relational Operators
System.out.println("a equals To b " + (a == b));
System.out.println("a Not equal To b " + (a != b));
System.out.println("a Greater than or equal To b " + (a >= b));
System.out.println("a Less than or equal To b " + (a <= b));
System.out.println("a Greater than b " + (a > b));
System.out.println("a less than b " + (a < b));
// // // 3.Logical Operatorss
System.out.println("Logical and " + ((a>b) && (b<a)));
System.out.println("Logical or " + ((a>=b) || (a<=b)));
System.out.println("Logical not " + !(a==b));
// // // 4.Assignment Operators
System.out.println("a = b " + (a = b));
System.out.println("a = a * b " +(a *= b));
System.out.println("a = a + b " +(a += b));
System.out.println("a = a - b " +(a -= b));
System.out.println("a = a / b " +(a /= b));
// // // 5.Bitwise Operator
System.out.println("Binary and " + (a & b));
System.out.println("Binary or " + (a | b));
System.out.println("Binary xor " + (a ^ b));
System.out.println("Binary one's complement " + ( ~ b));
System.out.println("Binary left shift " + (a << b));
System.out.println("Binary Right shift " + (a >> b));
}
}