About Lianga and Lian-minus: http://blog.csdn.net/ieayoio/article/details/46431843
Here's a code that's universally understood:
public static void Main (string[] args) {int a=3; SYSTEM.OUT.PRINTLN (a++ + 1);//4system.out.println (a);//4system.out.println (++a + 1);//6}
a++ is calculated first and then + +. and ++a the opposite.
In fact, in fact, at every step we use the rules we said above, where a++ + ++a equals 8. is because 3+5 equals 8, the first time I encounter a++ a value of 3, but after the run play value becomes 4, and after the ++a operation becomes 5
But look at the following procedure:
Due to the addition of a space in the middle, is understood in order to add, so now is 3+4 equals 7
Assuming the above understanding, the following piece of code is very easy:
In fact, it's 4+5=9, because it's ++a. So we'll start with + + and wait until the second ++a is calculated. A is already 4, so the answer is 9.
Look at a more complex example:
The following is an analysis:
Summary: So basically still master a++ is first to participate and calculate again ++,++a is the first + + to participate in and calculate, only a value change is not a formula to be done before the change. But every step of the calculation is likely to change.
This shows that the operation of the + + to the ordinary operation of the readability will be very poor, in addition, due to the impact of added. It is possible to accidentally make a result completely, so try not to let the + + operation into too complicated operations, can choose to replace him in a way
a++ and ++a in Java are analyzed in more complex operations