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

 

相关文章: