本帖最后由 杨佳名 于 2014-9-20 10:13 编辑
public void changeMethod_1(int a, int b){ System.out.println("changeMethod_1交换之前\ta:"+a+"\tb:"+b); a = a + b - (b = a); System.out.println("changeMethod_1交换之后\ta:"+a+"\tb:"+b); }
public void changeMethod_2(int a, int b){ System.out.println("changeMethod_2交换之前\ta:"+a+"\tb:"+b); b = a + (a = b)*0; System.out.println("changeMethod_2交换之后\ta:"+a+"\tb:"+b); }
public void changeMethod_3(int a, int b){ System.out.println("changeMethod_3交换之前\ta:"+a+"\tb:"+b); a = a + b; b = a - b; a = a - b; System.out.println("changeMethod_3交换之后\ta:"+a+"\tb:"+b); }
public void changeMethod_4(int a, int b){ System.out.println("changeMethod_4交换之前\ta:"+a+"\tb:"+b); a = a * b; b = a / b; a = a / b; System.out.println("changeMethod_4交换之后\ta:"+a+"\tb:"+b); }
public void changeMethod_5(int a, int b){ System.out.println("changeMethod_5交换之前\ta:"+a+"\tb:"+b); a = a^b; b = a^b; a = a^b; System.out.println("changeMethod_5交换之后\ta:"+a+"\tb:"+b); } |