java对象Integer不能引用传递

java对象Integer不能引用传递

 

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

 

原因:value 使用final 定义

 

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

 

转载于:https://www.cnblogs.com/rubekid/p/4077895.html

你可能感兴趣的:(java对象Integer不能引用传递)