java中的x ++和++ x有区别吗? [英] Is there a difference between x++ and ++x in java?
本文介绍了java中的x ++和++ x有区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
java中的++ x和x ++有区别吗?
Is there a difference between ++x and x++ in java?
推荐答案
++ x被称为preincrement而x ++是称为后增量。
++x is called preincrement while x++ is called postincrement.
int x = 5, y = 5;
System.out.println(++x); // outputs 6
System.out.println(x); // outputs 6
System.out.println(y++); // outputs 5
System.out.println(y); // outputs 6
这篇关于java中的x ++和++ x有区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文