Java Array Max Value findMax(T[] arr)

Here you can find the source of findMax(T[] arr)

Description

find Max

License

Open Source License

Declaration

public static <T extends Comparable<? super T>> T findMax(T[] arr) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static <T extends Comparable<? super T>> T findMax(T[] arr) {
        int maxIndex = 0;
        for (int i = 1; i < arr.length; i++)
            if (arr[i].compareTo(arr[maxIndex]) > 0)
                maxIndex = i;//w w w  . j  ava2  s  .c  om
        return arr[maxIndex];
    }
}

Related

  1. findMax(double[] values)
  2. findMax(int a, int b, int c, int d)
  3. findMax(int[] array)
  4. findMax(int[] v)
  5. findMax(int[] workArray, int idx)
  6. findMax2(int[] workArray, int idx, int max)
  7. findMaxAbs(float[] array)
  8. findMaxCommonPrefix(String path1, String path2)
  9. findMaxDiff(byte[] rand, byte[] newRand)