Java Array Max Value maxIdx(int[] in)

Here you can find the source of maxIdx(int[] in)

Description

max Idx

License

Apache License

Declaration

public static final int maxIdx(int[] in) 

Method Source Code

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

public class Main {
    public static final int maxIdx(int[] in) {
        int out = in[0];
        for (int i = 1; i < in.length; i++) {
            if (in[i] > in[out]) {
                out = i;//  w  ww.  j av a 2  s .c o m
            }
        }
        return out;
    }

    public static final int maxIdx(double[] in) {
        int out = 0;
        for (int i = 1; i < in.length; i++) {
            if (in[i] > in[out]) {
                out = i;
            }
        }
        return out;
    }

    public static final int maxIdx(float[] in) {
        int out = 0;
        for (int i = 1; i < in.length; i++) {
            if (in[i] > in[out]) {
                out = i;
            }
        }
        return out;
    }
}

Related

  1. maxElementIndex(final double[] array)
  2. maxElementIndex(final double[] array)
  3. maxElementIndex(final double[] array, final int endIndex)
  4. maxFloorDiv(int c, int... vals)
  5. maxFromDoubleArray(double[] arr)
  6. maximum(double[] list)
  7. maximum(float[] array)
  8. maximumDouble(double... values)
  9. maximumOf(final int[] array)