new Integer vs valueOf
        Posted  
        
            by LB 
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by LB 
        
        
        
        Published on 2010-06-04T13:28:35Z
        Indexed on 
            2010/06/07
            18:02 UTC
        
        
        Read the original article
        Hit count: 209
        
Hi,
I was using Sonar to make my code cleaner, and it pointed that I'm using new Integer(1) instead of Integer.valueOf(1). Because it seems that valueOf does not instantiate a new object so is more memory-friendly. How can valueOf not instantiate a new object ? How does it work ? Is this true for all integers ?
thanks.
© Stack Overflow or respective owner