实现2个整形变量的交换
int a = 10;
int b = 20;
System.out.println("a:"+a+",b:"+b);
//方法1:使用第三方变量(开发中常见)
int c ;
c = a;
a = b;
b = c;
System.out.println("a:"+a+",b:"+b);
//使用第2种方式
a = a + b;
b = a - b;//b = a + b - b = a
a = a - b;//a = a + b - a = b
//方式3:用位异或实现
//左边:a,b,a
//右边:a ^ b
a = a ^ b;
b = a ^ b;//a ^ b ^ b = a
a = a ^ b;//a ^ b ^ a = b
//方式4:一句话搞定
b = (a+b) - (a=b)
System.out.println("a:"+a+",b:"+b);