(二十)两种数据类型的对比

class Demo2
{
    public static void main(String[] args) {
        //int m=5,n=6;
        //huan(m,n);
        int[] a = new int[3];
        a[0] = 5;
        a[1] = 4;
        huan(a);//a[0]=4;a[1]=5;
    }
    public static void huan(int[] arr) {
        int c;
        c = arr[0];
        arr[0] = arr[1];
        arr[1] = c;
        System.out.println("a[0]=" + arr[0] + "a[1]=" + arr[1]);
    }
    public static void huan(int a,int b) {
        int c;
        c = a;
        a = b;
        b = c;
        System.out.println("a=" + a + "b=" + b);
    }
}

  

posted @ 2018-07-27 08:45  狗尾草的博客  阅读(304)  评论(0编辑  收藏  举报