Java Array Max Value max(T[] args)

Here you can find the source of max(T[] args)

Description

max

License

Apache License

Declaration

public static <T extends Comparable<T>> T max(T[] args) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static <T extends Comparable<T>> T max(T[] args) {
        if ((args == null) || (args.length == 0)) {
            return null;
        }/*from  w w w . ja v  a2s. c o  m*/
        T max = null;
        for (int i = 0; i < args.length; i++) {
            T t = args[i];
            if ((max == null) && (t != null)) {
                max = t;
            } else if (max.compareTo(t) < 1) {
                max = t;
            }
        }
        return max;
    }
}

Related

  1. max(Number... array)
  2. max(Number[] array)
  3. max(T first, T... others)
  4. max(T... elems)
  5. max(T... values)
  6. max_array(byte[] arr)
  7. max_index(int[] v)
  8. max_of_ints(int[] data)
  9. max_val_subsequence(int[] vals)