The title above sums up my question, to clarify things an example is:
array[0] = 1 array[1] = 3 array[2] = 7 // largest array[3] = 5
so th
Another functional implementation
int array[] = new int[]{1,3,7,5}; int maxIndex =IntStream.range(0,array.length) .boxed() .max(Comparator.comparingInt(i -> array[i])) .map(max->array[max]) .orElse(-1);