Java performs the increment operation after return on object references : <p>I have this code : </p>

<pre><code>public class counter {
    public static void main(String[] args){
        double[] array = new double[10];
        for(int i=0;i&lt;array.length;i++) array[i] = i;
        printArray(array);
        double result = doSomething(array);
        printArray(array);
    }
    public static void printArray(double[] arr){
        for(double d : arr) System.out.println(d);
    }
    public static double doSomething(double[] array){
        return array[0]++;
    }
}
</code></pre>

<p>I have learned that after the return statement no more code is executed and the increment++ increments the value at the next expression. So it seems logical to me that the the first element of the array <code>array[0]</code> should not be incremented.</p>

<p>However the output array is {1,1,2,3,4,5,6,7,8,9} </p>
