forked from Sonal0409/8PMJulyBatchJava-SeleniumPrograms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperatorsJava.java
More file actions
121 lines (48 loc) · 2.44 KB
/
OperatorsJava.java
File metadata and controls
121 lines (48 loc) · 2.44 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
109
110
111
112
113
114
115
116
117
118
119
120
121
package javaPrograms8PM;
public class OperatorsJava {
public static void main(String[] args) {
// TODO Auto-generated method stub
// Arithmetic Operators--- applied on variables storing numerical values
// Addition + : add 2 numbers
int a=10;
int b=20;
// c is a vairble which is toring the result of a+b
int c= a+b;
// in print statement a message or instruction will be written in double quotes
// if we want to print a varlable value, then the variable name will not be in double quotes
// here + operator is being used to concatenate
System.out.println("The result of a and b addition is :" + c); // print 30
double res= 10.23+20.45;
String s1=" Selenium";
String s2="training";
String s3= s1+" " +s2;
// here we want to print the final result of concatination of s1 and s2
System.out.println("Result of s1+s2 is :" + s3);
System.out.println(s1+s2);
// Increment operator ++
int x=100;
System.out.println("current value of x" + x);
// when ever we wnat to increase the value by 1 , we use increment operator
// ++x: increases the value by 1 and print it
System.out.println("value of x when we give ++x =" + ++x ); // 101
System.out.println("current value of x after ++x" + x);
// x++: increases the value by 1 and does not print it the incremented value
System.out.println("value of x when we give x++ " + x++);
System.out.println("current value of x after x++" + x);
System.out.println(x++);
// decrement
int y=200;
System.out.println("current value of y" + y);
System.out.println("value of y when we give --y =" + --y ); // 199
// Observe the result with y--
// Assignment : Declare 2 integer variables x and y and assign values it
// Declare a variable result1 to store result,
// use (-) operator on variables x and y and store the output in result1 and print it
// Declare 2 integer variables x1 and y1 and assign values it
// Declare a variable result2 to store the output,
// use (*) operator on variables x1 and y1 and store the output in result2 and print it
// Declare 2 integer variables x2 and y2 and assign values to it
// Declare a variable result3 to store the output,
// use (/) operator on variables x2 and y2 and store the output in result3 and print it
}
}