码迷,mamicode.com
首页 > 其他好文 > 详细

Integer引用类型问题

时间:2018-02-27 01:05:35      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:color   new   void   问题   一个   system   ring   div   static   

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引用类型问题

标签:color   new   void   问题   一个   system   ring   div   static   

原文地址:https://www.cnblogs.com/H-BolinBlog/p/8476362.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!