码迷,mamicode.com
首页 > 编程语言 > 详细

java对象Integer不能引用传递

时间:2014-11-06 10:44:59      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   使用   java   sp   div   on   

java对象Integer不能引用传递

 

 /** 
     * The value of the <code>Integer</code>. 
     * 
     * @serial 
     */  
    private final int value;  
  
    /** 
     * Constructs a newly allocated <code>Integer</code> object that 
     * represents the specified <code>int</code> value. 
     * 
     * @param   value   the value to be represented by the  
     *          <code>Integer</code> object. 
     */  
    public Integer(int value) {  
    this.value = value;  
    }

 

原因:value 使用final 定义

 

解决:可以使用原子类 AtomicInteger 来实现

 

java对象Integer不能引用传递

标签:style   blog   color   ar   使用   java   sp   div   on   

原文地址:http://www.cnblogs.com/rubekid/p/4077895.html

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