单独使用:自增自减运算符(后)(前)
单独写一行时,不论前后,结果都一样
参与计算
x++:先用后加,++x:先加后用
了解即可,单行更常用
package com.lxc.arithmeticoperator;
public class ArithmeticoperatorDmol5 {
public static void main(String[] args) {
int x = 10;
int y = x++;//先用后加,先把x赋值给y,再对x进行自增;
//x = 11,y = 10
int z = ++x;//先加后用,先对已经在对y求值时就已经自增过的x进行自增,再将x的值赋给z
//x = 12,z = 12
System.out.println("x:" + x);//12
System.out.println("y:" + y);//10
System.out.println("z:" + z);//12
}
}
标签:自增,12,++,System,运算符,0205,out
From: https://www.cnblogs.com/cxllxc/p/17276306.html