Here you can find the source of maxIndex(int[] values, int begin, int end)
public static int maxIndex(int[] values, int begin, int end)
//package com.java2s; //License from project: Open Source License public class Main { public static int maxIndex(int[] values) { return maxIndex(values, 0, values.length); }/*from w w w . j av a2s . c om*/ public static int maxIndex(int[] values, int begin, int end) { int max = Integer.MIN_VALUE; int index = -1; if (checkArguments(values, begin, end)) { max = values[begin]; index = begin; for (int i = begin; i < end; i++) { if (values[i] > max) { max = values[i]; index = i; } } } return index; } public static int maxIndex(double[] values) { return maxIndex(values, 0, values.length); } public static int maxIndex(double[] values, int begin, int end) { double max = Double.NaN; int index = -1; if (checkArguments(values, begin, end)) { max = values[begin]; index = begin; for (int i = begin; i < end; i++) { if (!Double.isNaN(values[i])) { if (values[i] > max) { max = values[i]; index = i; } } } } return index; } private static boolean checkArguments(final int[] values, final int begin, final int end) { if (values == null || values.length == 0) { return false; } if (begin < 0 || end >= values.length) { return false; } return true; } private static boolean checkArguments(final double[] values, final int begin, final int end) { if (values == null || values.length == 0) { return false; } if (begin < 0 || end > values.length) { return false; } return true; } }