整数变量不是引用类型吗?

时间:2018-11-05 10:19:37

标签: java types reference void

public static void main(String[] args) {
    // TODO Auto-generated method stub
    int a = 1;
    Integer b = new Integer("1");
    Integer c = a;
    int result = b + a;
    int[] f = new int[1];


    System.out.println(result);
    check(b);
    check1(f);
    Integer K = new Integer(10);
    int J = K.intValue();
    System.out.println(b + " " + f[0] );
    if(b.equals(a)) 
        System.out.println(a);
}

static void check(Integer d)
{
    d = 20;
}

static int[] check1(int[] a)
{
    a[0] = 20;

    return a;
}

首先,我很好奇要使用原始变量和引用变量。

让我知道如何显示

  

System.out.println(b)

     

输出

     

20

数组是引用类型,而int是原始类型。

,并且Integer是引用类型。但它不会从1更改为2

0 个答案:

没有答案
相关问题