Tutorial里讲得比较简单,不知道在说什么
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/op1.html
The only difference is that the prefix version (++result
) evaluates to the incremented value, whereas the postfix version (result++
) evaluates to the original value. If you are just performing a simple increment/decrement
Thinking in Java里解释得稍微好一点:
For pre-increment and pre-decrement (i.e., ++a or --a), the operation is performed and the value is produced. For post-increment and post-decrement (i.e., a++ or a--), the value is produced, then the operation is performed.
前缀的是先执行+1操作,然后把这个值产生;
后缀的是先得到这个原始值(可根据这个值执行一些方法),然后再执行+1操作。