forked from yrojha4ever/JavaStud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperatorTest.java
More file actions
64 lines (44 loc) · 1.13 KB
/
OperatorTest.java
File metadata and controls
64 lines (44 loc) · 1.13 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
public class OperatorTest {
public static void main(String[] args) {
int x = 5;
System.out.println(x++); // 5
System.out.println(x); // 6
int y = 10;
System.out.println(++y); // 11
System.out.println((17 % 3));
int z = 20;
z = z + 50; // 70
z += 50; // z = z + 50;
z *= 2; // z = z * 2;
// ==== &&===
int scimarks = 75;
if (scimarks > 0 && scimarks <= 100) {
if (scimarks >= 40) {
System.out.println("Ram is pass in science!");
} else {
System.out.println("Ram is failed in science!");
}
}
// =======ternary operator(? :)==========
boolean isPassed;
int mathMarks = 55;
// ---if else--
if (mathMarks >= 40) {
isPassed = true;
} else {
isPassed = false;
}
System.out.println("IS ram passed in Math: " + isPassed);
// ? : ternary operator
isPassed = (mathMarks >= 40) ? true : false;
System.out.println("IS ram passed in Math: " + isPassed);
// ========instanceof check Object type Class.=====
String s = "ABC";
if (s instanceof String) {
}
// Primitive: int Integer => use always Wrapper class.
Integer i = 55;
if (i instanceof Integer) {
}
}
}