Java Array Max Value maxIndex(double[] arrays)

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

Description

max Index

License

Apache License

Declaration

public static int maxIndex(double[] arrays) 

Method Source Code


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

import java.util.ArrayList;

public class Main {
    public static int maxIndex(double[] arrays) {
        int mIdx = -1;
        double maxValue = -Double.MAX_VALUE;
        for (int i = 0; i < arrays.length; i++) {
            if (arrays[i] > maxValue) {
                maxValue = arrays[i];//from w  w  w . j  av a 2 s .  c om
                mIdx = i;
            }
        }
        return mIdx;
    }

    public static int maxIndex(int[] counts) {
        int mIdx = -1;
        double maxValue = -Integer.MAX_VALUE;
        for (int i = 0; i < counts.length; i++) {
            if (counts[i] > maxValue) {
                maxValue = counts[i];
                mIdx = i;
            }
        }
        return mIdx;
    }

    public static int maxIndex(ArrayList<Double> list) {
        int mIdx = -1;
        double maxValue = -Double.MAX_VALUE;
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i) > maxValue) {
                maxValue = list.get(i);
                mIdx = i;
            }
        }
        return mIdx;
    }
}

Related

  1. maxIndex(double[] a)
  2. maxIndex(double[] arr)
  3. maxIndex(double[] arr)
  4. maxIndex(double[] array)
  5. maxIndex(double[] array)
  6. maxIndex(double[] doubles)
  7. maxIndex(double[] doubles)
  8. maxIndex(double[] doubles, int begin, int end)
  9. maxIndex(double[] v)