I would want to assign the array elements reversely into another array using this code. I need help.
int a[] = {1, 2, 3, 4, 5};
int aR[] = new int[a.length];
for (int i=0; i <= a.length; i++) {
for (int j=aR.length; j >= aR.length; j--) {
aR[j] = a[i];
}
}
System.out.println(Arrays.toString(aR));
I expect the output to be [5, 4, 3, 2, 1], but the output is an Array Exception.