Here is the code I wrote for reversing the elements in an array (Java) for example the last element becomes the first and so on. However, it doesn't quite work why is that?
public int[] reverse(int[] a) {
int[] temp = new int[a.length];
for (int i = 0; i < a.length - 1; i++) {
for (int u = a.length - 1; u >= 0; u--) {
temp[i] = a[u];
}
}
return temp;
}