不引入第三个变量如何实现两数交换数值

public class test02 {
    public static void main(String[] args) {
        int a = 10;
        int b = 5;
        System.out.println("交换前");
        System.out.println("a+"+a);
        System.out.println("b+"+b);
        a = a + b;
        b = a - b;
        a = a - b;
        System.out.println("交换后");
        System.out.println("a+"+a);
        System.out.println("b+"+b);
    }
}

你可能感兴趣的:(java)