java不用中间变量交换两个值

public void changeVal(){
        int a = 2;
        int b = 3;
        System.out.println("交换前  a:"+a+",b:"+b);
        a = a+b;
        b = a-b;
        a = a-b;
        System.out.println("交换后 a:"+a+",b:"+b);
        
    }

 

posted @ 2019-11-05 17:01  存钱罐  阅读(756)  评论(0编辑  收藏  举报