I'm trying to use recursion to find the largest number in the array, but am not getting the results i hoped. Any help would be very appreciated.
public class ArrayMax {
public static int largestInteger(int[] array) {
return FindlargestInteger(array, 0, -99999999);
}
public static int FindlargestInteger(int[] array, int index, int max) {
if (index == array.length)
return max;
if (array[index] > max) {
max = array[index];
}
FindlargestInteger(array, index + 1, max);
return max;
}
}
Integer.MIN_VALUEinstead of-99999999