I am supposed to be writing a program to reverse the numbers in an array recursively. I don't really know much code at this point. This is what I have so far.
This is the reverse method itself:
public static void reverse(int[] array, int i, int j)
{
if (i < j)
{
int temp = array[i];
array[i] = array[j];
array[j] = temp;
reverse(array, ++i, --j);
I am not sure if this is even right. I then have the main method.
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Enter size of the array");
int n = input.nextInt();
int[] array = new int[n];
for (int i =0; i <array.length; i++)
{
System.out.println("Enter number to be inputed into array.");
array[i] = input.nextInt();
}
System.out.println(array);
}
It is not printing out right and prints numbers and letter in text where I think it should be the array.