double[] a = new double[100];
a = b; // let b be some other double array[100]
Create an array named a of double with size of 100. Now when you a = b will copy the reference of b array to variable a.
+--------------------------------------------+ <- Suppose whole
a-> | 2.5 | | | | | | | | | | | | | | array is filled
+--------------------------------------------+ with value 2.5
+--------------------------------------------+ <- Suppose whole
b-> | 7.9 | | | | | | | | | | | | | | array is filled
+--------------------------------------------+ with value 7.9
after a = b
+--------------------------------------------+ <- Suppose whole
| 2.5 | | | | | | | | | | | | | | array is filled
+--------------------------------------------+ with value 2.5
a-> +--------------------------------------------+ <- Suppose whole
b-> | 7.9 | | | | | | | | | | | | | | array is filled
+--------------------------------------------+ with value 7.9
So now a and b pointing to same array.
public double[] function1(){
return somedouble[100];
}
double[] a = new double[100];
a = function1();
Now same thing is happening here. You create an array named a and then call function1() and again assigned the returning array reference to a.
System.arraycopy(function1(), 0, a, 0, 100);
Here the calling order will be
1 -> function1() will be called and the returning array reference will be saved in a temporary variable.
2 -> call to System.arraycopy(temporary variable, 0, a, 0, 100)
So function1() will be called only once.
As a side note make sure you use System.arraycopy(args) instead of System.arrayCopy(args)