知识站

 找回密码
 立即注册
知识站 首页 java 查看内容

java对象Integer不能引用传递

2020-3-7 07:51| 发布者: admin| 查看: 15| 评论: 0


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 来实现

发表评论

最新评论

Archiver|知识站 ( 鲁ICP备20004068号-1 )

鲁公网安备 37132502371390号

GMT+8, 2020-6-23 22:50 , Processed in 0.015786 second(s), 17 queries .

返回顶部