I am trying to reverse an int array in Java.
This method does not reverse the array.
for(int i = 0; i < validData.length; i++)
{
int temp = validData[i];
validData[i] = validData[validData.length - i - 1];
validData[validData.length - i - 1] = temp;
}
What is wrong with it?
It is most efficient to simply iterate the array backwards.
I'm not sure if Aaron's solution does this vi this call
Collections.reverse(list);
Does anyone know?below is the complete program to run in your machine.
For programs on matrix using arrays this will be the good source.Go through the link.