Here you can find the source of max(D... comparables)
Parameter | Description |
---|---|
D | data type |
comparables | a parameter |
static public <D extends Comparable<? super D>> D max(D... comparables)
//package com.java2s; // Subject to BSD License. See "license.txt" distributed with this package. public class Main { /**//from ww w.j a v a2s . c o m * Returns the maximum value. * A <tt>null</tt> value isn't compared. * If the paramter list is empty, the result is <tt>null</tt>. * @param <D> data type * @param comparables * @return the maximum value */ static public <D extends Comparable<? super D>> D max(D... comparables) { D max = null; for (int i = 0; i < comparables.length; i++) { D element = comparables[i]; if (element != null) { if (max == null || max.compareTo(element) < 0) { max = element; } } } return max; } }