如何用递归找出数组中的最大值
如:int[] a = {1,2,3,4,5,6,7,8,9,10};
如何用递归找出它的最大值?
static int max(int[] array) { return max(array, 0); } static int max(int[] array, int from) { if (from == array.length - 1) { return array[from]; } return Math.max(array[from], max(array, from + 1)); }