Java Array Max Value maxElementIndex(final double[] array)

Here you can find the source of maxElementIndex(final double[] array)

Description

max Element Index

License

Open Source License

Declaration

public static int maxElementIndex(final double[] array) 

Method Source Code

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

public class Main {
    public static int maxElementIndex(final double[] array) {
        return maxElementIndex(array, array.length);
    }/*from   ww w. ja v  a 2  s . c  om*/

    public static int maxElementIndex(final double[] array, final int start, final int endIndex) {
        if (array == null || array.length == 0)
            throw new IllegalArgumentException("Array cannot be null!");

        if (start > endIndex) {
            throw new IllegalArgumentException("Start cannot be after end.");
        }

        int maxI = start;
        for (int i = (start + 1); i < endIndex; i++) {
            if (array[i] > array[maxI])
                maxI = i;
        }
        return maxI;
    }

    public static int maxElementIndex(final double[] array, final int endIndex) {
        return maxElementIndex(array, 0, endIndex);
    }
}

Related

  1. maxDiffLocation(double[] list1, double[] list2)
  2. maxDistance(byte[] array, int maxDistance)
  3. maxDouble(double a, double... others)
  4. maxElement(double[] d)
  5. maxElement(int[] array)
  6. maxElementIndex(final double[] array)
  7. maxElementIndex(final double[] array, final int endIndex)
  8. maxFloorDiv(int c, int... vals)
  9. maxFromDoubleArray(double[] arr)