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

intmaxInArray(int[] values)
Returns the maximum value in an array of integers.
if ((values == null) || (values.length == 0)) {
    throw new IllegalArgumentException("Cannot find the max of a null or empty array.");
int max = values[0];
for (int value : values) {
    max = (max < value) ? value : max;
return max;
...
intmaxIndAbs(double[] a)
max Ind Abs
int maxi = 0;
double maxv = a[0];
for (int i = 1; i < a.length; i++) {
    if (Math.abs(a[i]) > maxv) {
        maxi = i;
        maxv = Math.abs(a[i]);
return maxi;
intmaxIndex(double values[])
Finds the index of the maximum value in the given vector.
double max = Double.NEGATIVE_INFINITY;
int maxIndex = 0;
int index = 0;
for (double value : values) {
    if (value > max) {
        max = value;
        maxIndex = index;
    index++;
return maxIndex;
intmaxIndex(double[] a)
Returns the index of the maximum value in array a.
int index = -1;
if (a != null && a.length != 0) {
    double max = a[0];
    index = 0;
    for (int i = 1; i < a.length; i++) {
        if (a[i] > max) {
            max = a[i];
            index = i;
...
intmaxIndex(double[] arr)
return index of maximal number
if (arr.length <= 0)
    return -1;
double max = Double.MIN_VALUE;
int index = 0;
for (int i = 0; i < arr.length; i++) {
    if (arr[i] > max) {
        max = arr[i];
        index = i;
...
intmaxIndex(double[] arr)
max index in array
double max = arr[0];
int index = 0;
for (int i = 0; i < arr.length; i++) {
    double val = arr[i];
    if (val > max) {
        max = val;
        index = i;
return index;
intmaxIndex(double[] array)
max Index
double max = -999.0;
int maxI = 0;
for (int i = 0; i < array.length; i++) {
    if (array[i] >= max) {
        max = array[i];
        maxI = i;
return maxI;
intmaxIndex(double[] array)
max Index
int i, size = array.length, maxIndex = 0;
double maxValue = array[maxIndex];
for (i = 1; i < size; i++) {
    if (maxValue < array[i]) {
        maxIndex = i;
        maxValue = array[maxIndex];
return maxIndex;
intmaxIndex(double[] arrays)
max Index
int mIdx = -1;
double maxValue = -Double.MAX_VALUE;
for (int i = 0; i < arrays.length; i++) {
    if (arrays[i] > maxValue) {
        maxValue = arrays[i];
        mIdx = i;
return mIdx;
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;