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

doublearrayMax(double[] arr)
A method to find max element in an array of doubles.
double max = Double.NEGATIVE_INFINITY;
for (double cur : arr)
    max = Math.max(max, cur);
return max;
doublearrayMax(double[] x)
array Max
if (x.length == 0) {
    throw new IllegalArgumentException();
double result = x[0];
for (int i = 1; i < x.length; i++) {
    if (result < x[i]) {
        result = x[i];
return result;
intarrayMax(final int[] array)
array Max
return array[maxElementIndex(array)];
intarrayMax(int[] property)
array Max
int[] copy = property.clone();
int max = 0;
int numElements = copy.length;
Arrays.sort(copy);
if (numElements > 0)
    max = copy[numElements - 1];
return max;
intarrayMaximum(int[] array)
array Maximum
if ((array == null) || (array.length == 0)) {
    throw new NoSuchElementException();
int q = array[0];
for (int i = 1; i < array.length; i++) {
    if (array[i] > q) {
        q = array[i];
return q;
doublefindMax(double newNumber, double currentMax)
Return the max between 2 numbers.
return Double.isNaN(currentMax) ? newNumber : currentMax > newNumber ? currentMax : newNumber;
doublefindMax(double[] arr)
find Max
double max = arr[0];
for (int i = 0; i < arr.length; i++) {
    if (max < arr[i]) {
        max = arr[i];
return max;
doublefindMax(double[] u, int startU, int length)
find Max
double max = -1;
int index = startU;
int stopIndex = startU + length;
for (; index < stopIndex; index++) {
    double val = u[index];
    val = (val < 0.0D) ? -val : val;
    if (val > max)
        max = val;
...
doublefindMax(double[] u, int startU, int length)
Returns the maximum magnitude of the complex numbers
double max = -1;
int index = startU * 2;
int stopIndex = (startU + length) * 2;
for (; index < stopIndex;) {
    double real = u[index++];
    double img = u[index++];
    double val = real * real + img * img;
    if (val > max) {
...
intfindMax(double[] values)
Return the index of the maximum value found in the array.
int maxIdx = 0;
for (int i = 0; i < values.length; ++i) {
    if (values[i] > values[maxIdx]) {
        maxIdx = i;
return maxIdx;