-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path03_Operators in java
46 lines (36 loc) · 1.29 KB
/
03_Operators in 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
public class operators
{
public static void main(String[] args)
{
int a = 4;
int b = 1000 + a; // arithmetic operator
System.out.println(b);
System.out.println(2<3); // comparision operator
int c =9;
c *= 4; // assignment operator
System.out.println(c);
System.out.println(64>4 || 64>9); // logical operator
System.out.println(2 & 3); // bitwise operator
// Precedence and associativity
int d = 6*5-34/2; // associativity from left to right
System.out.println(d);
// Resulting data type after arithmetic operation
byte x = 4;
int y = 5;
short z = 6;
int f = y + z;
float g = 5.88f + x;
System.out.println(f);
System.out.println(g);
// Increment and decrememt operator
int h = 33;
System.out.println(h++); // first it copies and then increments it
System.out.println(h);
System.out.println(++h); // first it increments then value and then value is copied
System.out.println(h);
// practice question
int m = 7;
int n = ++m * 8;
System.out.println(n);
}
}