I am trying to reverse the array order..but to no avail. I understand that there are existing methods, but i do not understand why mine does not work? When i try to reverse Array of [1,2] i get [2,2], when trying [1,2,3] i get a reverse array of [3,2,3] instead. I cannot see what is wrong with my method..please help thanks!
public static void reverseArray(int[] arr) {
int j = arr.length-1;
int [] temp = arr;
for (int i=0; i<arr.length; i++){
arr [i] = temp [j];
j--;
}
}