对两个整数变量的值进行互换

面试的时候用。
class OperateTest 
{
	public static void main(String[] args) {
        a = a ^ b; //a = 3 ^ 5;
        b = a ^ b; //b = (3^5)^5; b = 3;
        a = a ^ b; //a = (3^5)^3; a = 5;
<span style="white-space:pre">	</span>System.out.println("a="+a+",b="+b);
      }
}



posted @ 2014-10-15 22:57  Nearor  阅读(376)  评论(0编辑  收藏  举报