public static void mystery(int[] arr) {
int[] tmp = new int[arr.length];
tmp[0] = arr[arr.length-1];
tmp[arr.length-1] = arr[0];
arr = tmp;
}
int[] a = {2,3,4};
mystery(a);
When I run this, I get that even after calling mystery(a), the value of a is still
a = {2,3,4};
Java arrays are mutable, and all arguments are pass by reference. Since in the method arr points to the memory stored in tmp after the method, why is a unchanged?