I remember when talking function pass parameters, it is said the parameter will NOT get its value changed during function execution. but in my example, I observed my initial parameter value changed:
public static void main()
{
int[] a = new int[]{some int array};
int[] b = SortArray(a);
Output(a);
}
internal static int[] SortArray(int[] a)
{
int[] c = new int[a.length];
//Sort process, during which, both c[] and a[] are changing
return c;
}
when executing Output(a);
I found my a
is not the original one anymore. what's the trick here?