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 =
Your program will work for only length = 0, 1. You can try :
length = 0, 1
int i = 0, j = validData.length-1 ; while(i < j) { swap(validData, i++, j--); // code for swap not shown, but easy enough }