01 java中的自加运算符练习
作者:互联网
public class Test01{
public static void main(String[] args){
int a = 1;
int b = a++;//++在后,则先把a的值赋给b,然后a再自加1,这段代码执行后,b=1,a=2
int c = ++a;//++在前,先a自加1,然后赋值给c,这段代码执行后,a= 3,c=3
int x = 1;
int y = 2;
int t;
//实现x与y的值互换
t = y;
y = x;
x = t;
System.out.println("a="+a);//3
System.out.println("b="+b);//1
System.out.println("c="+c);//3
System.out.println("x="+x);
System.out.println("y="+y);
}
}
标签:01,int,System,运算符,++,println,自加,out 来源: https://www.cnblogs.com/liyuhong/p/15155484.html