Java Array Max Value findMax(double[] values)

Here you can find the source of findMax(double[] values)

Description

Return the index of the maximum value found in the array.

License

Open Source License

Parameter

Parameter Description
values the array of values from which the highest one is to be found

Return

the index of the highest value

Declaration

public static int findMax(double[] values) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from w  w w.  j a v a2s .  com
     * Return the index of the maximum value found in the array.
     * @param values the array of values from which the highest one is to be found
     * @return the index of the highest value
     */
    public static int findMax(double[] values) {

        int maxIdx = 0;

        for (int i = 0; i < values.length; ++i) {
            if (values[i] > values[maxIdx]) {
                maxIdx = i;
            }
        }
        return maxIdx;
    }
}

Related

  1. arrayMaximum(int[] array)
  2. findMax(double newNumber, double currentMax)
  3. findMax(double[] arr)
  4. findMax(double[] u, int startU, int length)
  5. findMax(double[] u, int startU, int length)
  6. findMax(int a, int b, int c, int d)
  7. findMax(int[] array)
  8. findMax(int[] v)
  9. findMax(int[] workArray, int idx)