Integer引用类型问题

Posted H_bolin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Integer引用类型问题相关的知识,希望对你有一定的参考价值。

public class TestMain {

    public static void main(String[] args) {
        Integer integer = 2;
        go(2);
        System.out.println(integer);
    }

    private static void go(Integer integer) {
        integer = 3; // 相当于int 3 封装了一个新的Integer: =new Integer(3); 自动装箱
        integer = new Integer(4);
    }
}

输入为:2

 

以上是关于Integer引用类型问题的主要内容,如果未能解决你的问题,请参考以下文章