-
Notifications
You must be signed in to change notification settings - Fork 13
/
Operators.java
41 lines (32 loc) · 934 Bytes
/
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
package lessons.languagebasics;
public class Operators {
public static void main(String[] args)
{
final double EXCHANGE_RATE = 18.54; //CONSTANT
final double PI = 3.142; //CONSTANT
// PI = 5.6; //ERROR
// EXCHANGE_RATE = 18.56; //ERROR
double b = 5 / 3;
System.out.println(b);
mathOp();
}
public static void mathOp()
{
int a = 5, b = 10;
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);
// a += b;
// a -= b;
// a *= b;
// a /= b;
// a %= b;
a++;
b = a++; // first assign b's value to a's value after that increment "a" with one
b = ++a; // increment "a" with one after that assign b's value to a's value after that
b = --a;
b = a--;
}
}