Surprisingly, I can't seem to find an answer to this anywhere.
I have initialized a new int array named "array" and done some things to it in a method named "reverse" and it returns array.length, how do I print the returned array in the main method and not the originally initialized array?
Here is my code, the for loop is what I am having problems with
public static void main(String[] args)
{
int array[] = new int [7];
array[0] = 5 ;
array[1] = 10;
array[2] = 11;
array[3] = 19;
array[4] = 13;
array[5] = 14;
array[6] = 16;
for(int i = 0; i < array.length; i++)
{
System.out.println(array[i]);
}
}
public int reverse(int[] array) {
int left = 0;
int right = array.length - 1;
while( left < right )
{
int temp = array[left];
array[left] = array[right];
array[right] = temp;
left++;
}
return array.length;}