Java Utililty Methods Collection Max

List of utility methods to do Collection Max

Description

The list of methods to do Collection Max are organized into topic(s).

Method

longcalculateMaxTime(Collection times)
Calculate the biggest so the slowest execution time.
long maxTime = 0;
for (long value : times) {
    maxTime = value > maxTime ? value : maxTime;
return maxTime;
Stringformat(String theLabel, Collection coll, int maxNumberReported, String theClassName)
Format a collection, array, or map (internal method).
final boolean showCollectionIndexes = false;
final int half = (maxNumberReported == 0) ? 10000 : ((maxNumberReported - 1) / 2) + 1;
String label = theLabel;
if (label == null) {
    label = "";
final Map<Class<?>, Integer> instancesByClass = new HashMap<Class<?>, Integer>();
final StringBuilder sb = new StringBuilder(label);
...
intgetMaximumElementLength(final Collection collection)
Returns the maximum length of any element in a Collection.
int max = 0;
for (Object object : collection) {
    if (object.toString().length() > max) {
        max = object.toString().length();
return max;
Tmax(Collection coll)
max
return Collections.max(coll);
Doublemax(Collection data)
max
return Collections.max(data);
doublemax(Collection doubles)
max
if (doubles.size() < 1)
    throw new IllegalArgumentException("No items in list");
Double max = 0d;
for (Double doubleVal : doubles) {
    if (doubleVal > max)
        max = doubleVal;
return max;
...
Doublemax(Collection values)
max
List<Double> filteredValues = filterNulls(values);
if (filteredValues.size() == 0)
    return null;
return Collections.max(filteredValues);
intmax(Collection collection)
max
List<Integer> list = new ArrayList<Integer>(collection);
Collections.sort(list);
return list.get(list.size() - 1);
Numbermax(Collection list)
max
Number max = list.iterator().next();
for (Number item : list) {
    if (item.floatValue() > max.floatValue()) {
        max = item;
return max;
Stringmax(Collection strs)
max
String max = null;
for (String s : strs) {
    if (max == null || max.compareTo(s) < 0)
        max = s;
return max;