reverse an array in java using for loop