java不用中间变量交换两个值
public void changeVal(){ int a = 2; int b = 3; System.out.println("交换前 a:"+a+",b:"+b); a = a+b; b = a-b; a = a-b; System.out.println("交换后 a:"+a+",b:"+b); }
if you want to go fast,go alone,if you want to go far,go together
public void changeVal(){ int a = 2; int b = 3; System.out.println("交换前 a:"+a+",b:"+b); a = a+b; b = a-b; a = a-b; System.out.println("交换后 a:"+a+",b:"+b); }