Is that how 'Long' works (in Java)?
<p>Look at this Java code:</p>

<pre><code>class PerformanceTest2{

    public static void main(String args[]){

        Long sum = 0L;

        for(int i=0;i&lt;Integer.MAX_VALUE;i++)
            sum += i;

        System.out.println("Sum = " + sum);
    }
} 
</code></pre>

<p>It is observed that it takes longer for this code since sum is 'Long' &amp; not 'long'. So in every iteration what happens is:</p>

<pre><code>sum = new Long(sum.longValue() + i); (for sum+=i;)
</code></pre>

<p>So, a new object is created every time. Doesn't Java support C++ like feature of returning a reference so that we could've written (possibly):</p>

<pre><code>sum.longValue() += i;
</code></pre>

<p>possibly not having to create sum object every time around the loop? Am I right? </p>
