Here you can find the source of argmax(int[] array)
public static final int argmax(int[] array)
//package com.java2s; // terms of the Lesser GNU General Public License (LGPL) public class Main { /**//from www. jav a 2 s . c om * @deprecated * @see getArgmax() */ public static final int argmax(int[] array) { return getArgmax(array); } /** * @deprecated * @see getArgmax() */ public static final int argmax(double[] array) { return getArgmax(array); } /** * Find the maximum "argument" * @param array The array to examine * @return the element of the array with the maximum value * @note if array is zero length returns -1 */ public static final int getArgmax(int[] array) { if (array.length == 0) { return -1; } int maxValue = array[0]; int maxIndex = 0; for (int i = 1; i < array.length; i++) { final int v = array[i]; if (v > maxValue) { maxValue = v; maxIndex = i; } } return maxIndex; } /** * Find the maximum "argument" (of a double array) * @param array The array to examine * @return the element of the array with the maximum value * @note if array is zero length returns -1 */ public static final int getArgmax(double[] array) { if (array.length == 0) { return -1; } double maxValue = array[0]; int maxIndex = 0; for (int i = 1; i < array.length; i++) { final double v = array[i]; if (v > maxValue) { maxValue = v; maxIndex = i; } } return maxIndex; } }