Java Utililty Methods Array Max Value

List of utility methods to do Array Max Value

Description

The list of methods to do Array Max Value are organized into topic(s).

Method

intmaxIndex(double[] doubles)
Returns index of maximum element in a given array of doubles.
double maximum = 0;
int maxIndex = 0;
for (int i = 0; i < doubles.length; i++) {
    if ((i == 0) || (doubles[i] > maximum)) {
        maxIndex = i;
        maximum = doubles[i];
return maxIndex;
intmaxIndex(double[] doubles, int begin, int end)
max Index
if (doubles == null || doubles.length == 0) {
    return -1;
double max = doubles[begin];
int pos = begin;
for (int i = begin + 1; i < end; i++) {
    if (max < doubles[i]) {
        max = doubles[i];
...
intmaxIndex(double[] v)
Gets the index of the maximum element in the array.
if (v == null || v.length == 0) {
    throw new IllegalArgumentException("v cannot be empty.");
double maxValue = maxValue(v);
for (int i = 0; i < v.length; i++) {
    if (v[i] == maxValue) {
        return i;
return -1; 
doublemaxIndex(double[] value)
returns the index of the greatest element from the given array
double result = Double.NEGATIVE_INFINITY;
int index = 0;
for (int i = 0; i < value.length; i++) {
    if (value[i] > result)
        result = value[i];
    index = i;
return index;
...
intmaxIndex(double[] x, int length)
max Index
double m = Double.NEGATIVE_INFINITY;
int mi = -1;
for (int i = 0; i < length; i++)
    if (x[i] > m) {
        m = x[i];
        mi = i;
return mi;
...
intmaxIndex(final double[] a)
Return the index that has the max value.
int result = -1;
double max = Double.NEGATIVE_INFINITY;
for (int i = 0; i < a.length; i++) {
    if (a[i] > max) {
        max = a[i];
        result = i;
return result;
intmaxIndex(final double[] values)
Finds the maximum value of an array of double and returns its index in the array.
if ((values != null) && (values.length != 0)) {
    double max = 0;
    int maxIndex = -1;
    for (int i = 0; i < values.length; i++) {
        if (values[i] > max) {
            max = values[i];
            maxIndex = i;
    return maxIndex;
} else {
    throw new IllegalArgumentException("cannot calculate maximum index of null or empty array of values");
intmaxIndex(float[] arr)
Returns the index to the smallest value in the array
float max = Float.MIN_VALUE;
int index = 0;
for (int i = 0; i < arr.length; i++) {
    if (arr[i] > max) {
        max = arr[i];
        index = i;
return index;
intmaxIndex(float[] from, int start)
max Index
int result = start;
for (int i = start; i < from.length; ++i)
    if (from[i] > from[result])
        result = i;
return result;
intmaxIndex(float[] x)
Get the index of the maximum (largest) value in an array In the event of a tie, the first index is returned
float maxValue = -Float.MAX_VALUE;
int maxIndex = -1;
for (int i = 0; i < x.length; i++) {
    if (x[i] > maxValue) {
        maxValue = x[i];
        maxIndex = i;
return maxIndex;