Java Array Max Value max(T... elems)

Here you can find the source of max(T... elems)

Description

max

License

Open Source License

Declaration

static <T extends Comparable<? super T>> T max(T... elems) 

Method Source Code

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

public class Main {
    static <T extends Comparable<? super T>> T max(T... elems) {

        if (elems.length == 0)
            return null;

        T best = elems[0];/*w  w w  .  jav  a  2s.  c  om*/

        for (T t : elems) {
            if (t.compareTo(best) > 0) {
                best = t;
            }
        }

        return best;

    }
}

Related

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