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