java for i i 区别,i ++amp;和i ++之间的区别是什么? ++我在for循环(Java)?
hello, I've just started learning Java and now I'm into for loop statement. I don't understand how ++i i++ works in a for loop statement.
I mean how they work in mathematics operations like addition and subtraction. I hope some one will explain this to me.
解決方案
They both increment the number. ++i is equivalent to i = i + 1.
i++ and ++i are very similar but not exactly the same. Both increment the number, but ++i increments the number before the current expression is evaluted, whereas i++ increments the number after the expression is evaluated.
int i = 3;
int a = i++; // a = 3, i = 4
int b = ++a; // b = 4, a = 4
總結(jié)
以上是生活随笔為你收集整理的java for i i 区别,i ++amp;和i ++之间的区别是什么? ++我在for循环(Java)?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Linux学习笔记(一):Linux介绍
- 下一篇: 如何添加JWT生成的token在请求头中