class FuZhi {
public static void main(String[] args) {
//定义两个int类型的整数
int a = 3, b = 4;
System.out.println("a = " + a + "b = " + b);
//用异或运算符交换两个数????问问这个交换的具体流程
a = a ^ b;//a^b的值赋给a 011^100=111 (异或:相同为假,不同为真)
System.out.println(a); //a=7
b = a ^ b;//a^b的值赋给b 111^100=011
System.out.println(b); //b=3
a = a ^ b;//a^b的值赋给a 111^011=100
System.out.println(a); //a=4
System.out.println("a = " + a + "b = " + b);
}
}
|