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

NumbermaxNum(Number iArr[])
max Num
if (iArr == null || iArr.length <= 0) {
    return null;
Number rtn = iArr[0];
for (int i = 1; i < iArr.length; i++) {
    if (rtn.doubleValue() > iArr[i].doubleValue()) {
        continue;
    if (rtn.doubleValue() < iArr[i].doubleValue()) {
        rtn = iArr[i];
        continue;
return rtn;
doublemaxOfSortedValues(double[] sortedValues)
max Of Sorted Values
return sortedValues[sortedValues.length - 1];
doublemaxOverArraySubset(double[] array, Iterable subset)
Compute the maximum value over a subset of an array of doubles.
double d;
d = Double.NEGATIVE_INFINITY;
for (int j : subset) {
    if (array[j] > d)
        d = array[j];
return d;
float[]maxpool(float[] curr, float[] probs)
Takes the maximum value at each position
if (curr.length != probs.length) {
    throw new IllegalArgumentException("Float[] need to have the same size");
float[] _ret = new float[curr.length];
for (int i = 0; i < curr.length; i++) {
    if (curr[i] > probs[i]) {
        _ret[i] = curr[i];
    } else {
...
intmaxPosition(float[] v)
max Position
int pos = 0;
Float max = Float.MIN_VALUE;
for (int i = 0; i < v.length; ++i) {
    if (v[i] > max) {
        pos = i;
        max = v[i];
return pos;
intmaxPositive(int[] array)
max Positive
int res = 0;
if (max(array) > 0)
    res = max(array);
return res;
intmaxPrim(final int... numbers)
max Prim
int max = Integer.MIN_VALUE;
for (final int n : numbers) {
    max = Math.max(max, n);
return max;
intmaxRepeating(int[] input, int k)
max Repeating
for (int i = 0; i < input.length; i++) {
    int indexToIncrease = input[i] % k;
    input[indexToIncrease] = input[indexToIncrease] + k;
int max = input[0], result = 0;
for (int i = 1; i < input.length; i++) {
    if (input[i] > max) {
        max = input[i];
...
intmaxRow(Object[]... arr)
Returns the first row's index having the maximum length in a 2D array.
int maxRowLength = arr[0].length;
int maxRow = 0;
for (int i = 1; i < arr.length; i++) {
    if (maxRowLength < arr[i].length) {
        maxRowLength = arr[i].length;
        maxRow = i;
return maxRow;
intmaxRowLen(Object[]... arr)
max Row Len
return arr[maxRow(arr)].length;