Java Array Max Value max_index(int[] v)

Here you can find the source of max_index(int[] v)

Description

maindex

License

LGPL

Declaration

public static int max_index(int[] v) 

Method Source Code

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

public class Main {
    public static int max_index(int[] v) {
        int a = v[0];
        int i = 0;

        for (int j = 1; j < v.length; j++) {
            if (v[j] > a) {
                a = v[j];//from w  ww  . j a  va  2 s . com
                i = j;
            }
        }
        return i;
    }

    public static int max_index(double[] v) {
        double a = v[0];
        int i = 0;

        for (int j = 1; j < v.length; j++) {
            if (v[j] > a) {
                a = v[j];
                i = j;
            }
        }
        return i;
    }
}

Related

  1. max(T first, T... others)
  2. max(T... elems)
  3. max(T... values)
  4. max(T[] args)
  5. max_array(byte[] arr)
  6. max_of_ints(int[] data)
  7. max_val_subsequence(int[] vals)
  8. maxAbs(double[] a, int begin, int end)
  9. maxAbs(float[] a, int off, int length)