Write the definition of a method reverse , whose parameter is an array of integers. The method reverses the elements of the array. The method does not return a value
So far I got:
public void reverse(int[] backward)
{
for(int i = (backward.length -1); i >=0;i--){
}
}
I think I'm suppose to swap forward array and reverse arrays some how but I don't how to go about doing that like in this one
Reversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the second with the next to the last, and so on, all the way to the middle of the array.
Given an array a and two other int variables, k and temp , write a loop that reverses the elements of the array.
Do not use any other variables besides a , k , and temp .
so far i got:
int temp = a.length;
for (k = 0; k < temp; k++)
{
a[temp - 1] = a[k];
}
Please help me with these two thank you!