public class test02 {
/**
*测试^
* @param args
*/
public static void main(String[] args) {
test02.f1(23, 54);
test02.f2(23, 54);
test02.f3(23, 54);
}
/**
* 借助第三者交换两者
*/
public static void f1 (int n ,int m){
int y = 0;
y = n;
n = m;
m = y;
System.out.println("n = "+n+","+"m="+m);
}
/**
* 借用两者之和交换两者
*/
public static void f2(int n ,int m ){
int sum = n+m;
n = sum - m;
m = sum - n;
System.out.println("n = "+n+","+"m="+m);
}
/**
* 借用异或运算符来交换两者。
*/
public static void f3(int n,int m){
n = n^m;
m = n^m;
n = n^m;
System.out.println("n = "+n+","+"m="+m);
}
}