Java Array Max Value maxIndex(double[] arr)

Here you can find the source of maxIndex(double[] arr)

Description

return index of maximal number

License

Apache License

Declaration

public static int maxIndex(double[] arr) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*  w  w  w . j  a  v  a2 s .  co  m*/
     * return index of maximal number
     */
    public static int maxIndex(double[] arr) {

        if (arr.length <= 0)
            return -1;

        double max = Double.MIN_VALUE;
        int index = 0;

        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
                index = i;
            }
        }

        return index;
    }
}

Related

  1. maxInArray(int[] values)
  2. maxIndAbs(double[] a)
  3. maxIndex(double values[])
  4. maxIndex(double[] a)
  5. maxIndex(double[] arr)
  6. maxIndex(double[] array)
  7. maxIndex(double[] array)
  8. maxIndex(double[] arrays)
  9. maxIndex(double[] doubles)