It gives me out of bound exception. And it seems not to recognize the first element in the array.
public class MaximumRec {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] A = {90, 45,12,19,72,55,15,19};
int x = maximumR(A,8);
System.out.print(x);
}
static int maximumR(int[] A, int n)
{
int max;
if (n == 1)
{
return A[n];
}
else
{
max = maximumR(A, n-1);
if(max < A[n] )
{
max = A[n];
}
}
return max;
}
}