//第1种办法
public void changeMethodA(int a, int b){
System.out.println(“changeMethodA交换之前 a:”+a+” b:”+b);
a = a + b – (b = a);
System.out.println(“changeMethodA交换之后 a:”+a+” b:”+b);
}
//第2种办法
public void changeMethodB(int a, int b){
System.out.println(“changeMethodB交换之前 a:”+a+” b:”+b);
b = a + (a = b)*0;
System.out.println(“changeMethodB交换之后 a:”+a+” b:”+b);
}
//第3种办法
public void changeMethodC(int a, int b){
System.out.println(“changeMethodC交换之前 a:”+a+” b:”+b);
a = a + b;
b = a – b;
a = a – b;
System.out.println(“changeMethodC交换之后 a:”+a+” b:”+b);
}
//第4种办法
public void changeMethodD(int a, int b){
System.out.println(“changeMethodD交换之前 a:”+a+” b:”+b);
a = a * b;
b = a / b;
a = a / b;
System.out.println(“changeMethodD交换之后 a:”+a+” b:”+b);
}
//第5种办法
public void changeMethodE(int a, int b){
System.out.println(“changeMethodE交换之前 a:”+a+” b:”+b);
a = a^b;
b = a^b;
a = a^b;
System.out.println(“changeMethodE交换之后 a:”+a+” b:”+b);
}