Java Array Max Value maxIndex(int[] array)

Here you can find the source of maxIndex(int[] array)

Description

max Index

License

Apache License

Return

the maximum index in this array,

Declaration

public static int maxIndex(int[] array) 

Method Source Code

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

public class Main {
    /**//from   w ww.java 2 s .c  o m
     * @return the maximum index in this array,
     */
    public static int maxIndex(int[] array) {
        int maxIndex = 0;
        for (int i = 0; i < array.length; i++) {
            if (array[maxIndex] < array[i]) {
                maxIndex = i;
            }
        }
        return maxIndex;
    }

    /**
     * @return the maximum index in this array,
     */
    public static int maxIndex(long[] array) {
        int maxIndex = 0;
        for (int i = 0; i < array.length; i++) {
            if (array[maxIndex] < array[i]) {
                maxIndex = i;
            }
        }
        return maxIndex;
    }

    /**
     * @return the maximum index in this array,
     */
    public static int maxIndex(double[] array) {
        int maxIndex = 0;
        for (int i = 0; i < array.length; i++) {
            if (array[maxIndex] < array[i]) {
                maxIndex = i;
            }
        }
        return maxIndex;
    }
}

Related

  1. maxIndex(final double[] values)
  2. maxIndex(float[] arr)
  3. maxIndex(float[] from, int start)
  4. maxIndex(float[] x)
  5. maxIndex(int[] a)
  6. maxIndex(int[] from)
  7. maxIndex(int[] list)
  8. maxIndex(int[] shape)
  9. maxIndex(int[] values, int begin, int end)