Here you can find the source of maxIndex(double values[])
Parameter | Description |
---|---|
values | the vector |
public static int maxIndex(double values[])
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w ww .j ava 2 s . com*/ * Finds the index of the maximum value in the given vector. * @param values the vector * @return index of the maximum in the given vector */ public static int maxIndex(double values[]) { double max = Double.NEGATIVE_INFINITY; int maxIndex = 0; int index = 0; for (double value : values) { if (value > max) { max = value; maxIndex = index; } index++; } return maxIndex; } /** * Finds the index of the maximum value in the given vector. * @param values the vector * @return index of the maximum in the given vector */ public static int maxIndex(int values[]) { int max = Integer.MIN_VALUE; int maxIndex = 0; int index = 0; for (int value : values) { if (value > max) { max = value; maxIndex = index; } index++; } return maxIndex; } }