本文介绍了i ++&之间有什么区别? ++ i在for循环中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚开始学习Java,现在我进入了for循环语句.我不明白++i和i++在for循环中如何工作.
I've just started learning Java and now I'm into for loop statements. I don't understand how ++i and i++ works in a for-loop.
它们如何在加减运算等数学运算中起作用?
How do they work in mathematics operations like addition and subtraction?
推荐答案它们都增加数字. ++i等同于i = i + 1.
They both increment the number. ++i is equivalent to i = i + 1.
i++和++i非常相似,但不完全相同.两者都会增加数字,但是++i会增加对当前表达式求值之前的数字,而i++会增加对表达式求值之后的数字.
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更多推荐
i ++&之间有什么区别? ++ i在for循环中?
发布评论