Open brush face questions, questions are carried out in accordance with the video brushed
Increment variable, just remember two things
- i ++ is calculated after the first assignment
- ++ i is calculated after the first assignment
Look at the following code
int i = 1;
i = i++;
int j = i++;
int k = i + ++i * i++;
System.out.println("i="+ i);
System.out.println("j=" +j);
System.out.println("k="+ k);
Here we must note two points
- Increment variable algorithm
- Operator precedence
Results are as follows
i=4
j=1
k=11
I'm just afraid of the same, and that is good enough for my suffering!