im trying to do this
Write a recursive method that has as arguments an array of characters and two bounds on
array indexes. The method should reverse the order of those entries in the array whose
indexes are between the two bounds (inclusive). For example, suppose the array is:
a[0] = ‘A’ a[1] = ‘B’ a[2] = ‘C’
a[3] = ‘D’ a[4] = ‘E’
and the bounds are 1 and 4. Then, after the method is run the array elements should be:
a[0] = ‘A’ a[1] = ‘E’ a[2] = ‘D’
a[3] = ‘C’ a[4] = ‘B’
this is what i currently have
public class recursion2
{
public static int reverse(int [] a,int n, int r)
{
if(n < a[r])
{
r = a[n];
return reverse(a,n - 1,r);
}
return r;
}
public static void main(String [] args)
{
int[] reverse = {'A','B','C','D','E'};
int reverse2 = reverse(reverse,reverse.length-1,reverse[0]);
System.out.println("order is: "+ reverse2);
}
}
im currently getting errors on it