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

intmax(final int[] arr)
Getter.
if (arr.length == 0)
    throw new IllegalArgumentException("must not be empty");
int max = Integer.MIN_VALUE;
for (final int v : arr) {
    if (v > max) {
        max = v;
return max;
int[]max(final int[] result, final int[] vec1, final int[] vec2)
max
for (int i = 0; i < result.length; i++) {
    result[i] = Math.max(vec1[i], vec2[i]);
return result;
intmax(final int[] values)
max
int max = -1;
for (int v : values) {
    max = Math.max(v, max);
return max;
intmax(final int[] values)
Finds that maximum of a list of integers.
int m = Integer.MIN_VALUE;
for (int v : values) {
    if (v > m) {
        m = v;
return m;
longmax(final long[] longs)
Get the maximum element in an array of longs.
long max = 0l;
for (int j = 0; j < longs.length; j++) {
    max = (longs[j] > max) ? longs[j] : max;
return max;
Numbermax(final Number... numbers)
max
double max = Double.MIN_VALUE;
for (final Number n : numbers) {
    final double d = n.doubleValue();
    max = Math.max(max, d);
return max;
Tmax(final T p_enum1, final T p_enum2, final T[] enumValues)
max
if (p_enum1 == null) {
    return p_enum2;
if (p_enum2 == null) {
    return p_enum1;
return enumValues[Math.max(p_enum1.ordinal(), p_enum2.ordinal())];
Tmax(final T... elements)
max
T max = elements[0];
for (final T element : elements) {
    if (0 < element.compareTo(max)) {
        max = element;
return max;
floatmax(float... a)
max
switch (a.length) {
case 0:
    return Float.NaN;
case 1:
    return a[0];
case 2:
    return Math.max(a[0], a[1]);
case 3:
...
floatmax(float... fs)
max
float max = 0;
if (fs.length > 0) {
    max = fs[0];
    for (float f : fs) {
        if (f > max) {
            max = f;
return max;