Java Collection Max max(Collection values)

Here you can find the source of max(Collection values)

Description

max

License

Open Source License

Declaration

public static Double max(Collection<Double> values) 

Method Source Code


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

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class Main {
    public static Double max(Collection<Double> values) {
        List<Double> filteredValues = filterNulls(values);
        if (filteredValues.size() == 0)
            return null;

        return Collections.max(filteredValues);
    }/*from w  w w . ja  v a 2s.  c  o m*/

    private static List<Double> filterNulls(Collection<Double> values) {
        List<Double> result = new ArrayList<>();
        for (Double value : values) {
            if (value != null)
                result.add(value);
        }

        return result;
    }
}

Related

  1. format(String theLabel, Collection coll, int maxNumberReported, String theClassName)
  2. getMaximumElementLength(final Collection collection)
  3. max(Collection coll)
  4. max(Collection data)
  5. max(Collection doubles)
  6. max(Collection collection)
  7. max(Collection list)
  8. max(Collection strs)
  9. max(Collection col)