I\'m a programming beginner and I have question regarding a return value from a function.
I´m studying Java.
I have attached code from my book that features a cl
Since arrays are objects, they are passed by their reference (their location in memory), so the changes within sort()
to a[]
also change a[]
declared in main. So a is changed within the function. However, you cannot say
public static void change(int[] a) {
a = new int[3];
a = {1, 2};
}
That will not change a
itself, because that just makes a new memory location that the parameter a
points to, without changing the parameter.