两个变量交换

        int a = 2;
        int b = 7;
        a = a + b;
        b = a - b;  // b = a + b - b = a
        a = a - b;  // a + b - a = b


--------------------------------------------------------

        int a = 2;
        int b = 7;
        a = a ^ b;
        b = a ^ b;
        a = a ^ b;

 

两个变量交换

上一篇:Hadoop常用命令总结


下一篇:了解你的系统