-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtutorial_11.java
More file actions
36 lines (26 loc) · 828 Bytes
/
tutorial_11.java
File metadata and controls
36 lines (26 loc) · 828 Bytes
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
class Driver {
public static void main(String[] args) {
int a = 0, b = 0, c = 0;
// post-incrementation. adds one to your variable
a++;
// a=1, b=0, c=0
// pre-incrementation. adds one to your variable
++a;
// a=2, b=0, c=0
// post-decrementation. subtracts one from your variable
a--;
// a=1, b=0, c=0
// pre=decrementation. subtracts one from your variable
--a;
// a=0, b=0, c=0
// do operations left to right.
a = b++; // same as: a = b; b += 1;
// a=0, b=1, c=0
a = ++b; // same as: a = (b += 1);
// a=2, b=2, c=0
a = c--; // same as: a = c; c -= 1;
// a=0, b=2, c=-1
a = --c; // same as: a = (c -= 1);
// a=-2, b=2, c=-2
}
}