Java Array Max Value maxIndex(double[] arr)

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

Description

max index in array

License

Open Source License

Parameter

Parameter Description
arr a parameter

Declaration

public static int maxIndex(double[] arr) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from w ww.j a va 2s  .c o  m
     * max index in array
     *
     * @param arr
     * @return
     */
    public static int maxIndex(double[] arr) {
        double max = arr[0];
        int index = 0;

        //        for (double val : arr) {
        for (int i = 0; i < arr.length; i++) {
            double val = arr[i];

            if (val > max) {
                max = val;
                index = i;
            }
        }

        return index;
    }
}

Related

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