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

intfindMax(int a, int b, int c, int d)
find Max
int result = Math.max(a, b);
result = Math.max(result, c);
result = Math.max(result, d);
return result;
ArrayListfindMax(int[] array)
Finds the indexes of the largest values in an integer array.
ArrayList<Integer> fields = null;
int value = -1;
for (int i = 0; i < array.length; i++) {
    if (array[i] > value) {
        fields = new ArrayList<>();
        fields.add(i);
        value = array[i];
    } else if (array[i] == value) {
...
intfindMax(int[] v)
Find the greatest value from an array of integer
int max = Integer.MIN_VALUE;
for (int i = 0; i < v.length; ++i) {
    if (v[i] > max) {
        max = v[i];
return max;
intfindMax(int[] workArray, int idx)
find Max
return findMax2(workArray, idx, workArray[idx]);
TfindMax(T[] arr)
find Max
int maxIndex = 0;
for (int i = 1; i < arr.length; i++)
    if (arr[i].compareTo(arr[maxIndex]) > 0)
        maxIndex = i;
return arr[maxIndex];
intfindMax2(int[] workArray, int idx, int max)
find Max
if (idx <= 0)
    return max;
return findMax2(workArray, idx - 1, Math.max(max, workArray[idx - 1]));
floatfindMaxAbs(float[] array)
Finds maximal abs element in array
float max = 0;
for (int i = 0; i < array.length; i++) {
    if (Math.abs(array[i]) > max) {
        max = array[i];
return max;
StringfindMaxCommonPrefix(String path1, String path2)
Find maximum common prefix of path1 and path2
int i = 0;
int len1 = path1.length();
int len2 = path2.length();
while ((i < len1) && (i < len2)) {
    if (path1.charAt(i) != path2.charAt(i)) {
        break;
    i++;
...
intfindMaxDiff(byte[] rand, byte[] newRand)
find Max Diff
int maxDiff = 0;
for (int i = 0; i < rand.length; i++) {
    int diff = Math.abs(rand[i] - newRand[i]);
    if (diff > maxDiff)
        maxDiff = diff;
return maxDiff;
intfindMaximumUnitFor(long elapsed, int specifiedMax)
find Maximum Unit For
int theUnit = specifiedMax;
while (elapsed < MILLIS_PER_UNIT[theUnit] && theUnit > SECONDS_UNITS) {
    theUnit--;
return theUnit;