- public class mySwap
- {
- public static void main(String[] args)
- {
- int a = 6;
- int b = 9;
-
- System.out.println("before swap is ");
- System.out.println("a="+a+";b="+b);
-
- a=a^b;
- b=b^a;
- a=a^b;
-
- System.out.println("after swap is ");
- System.out.println("a="+a+";b="+b);
- }
- }
复制代码
如果取数去验证的话,那么,这个方法是OK的,我很佩服这些能想到这些方法的大神们。 |
|