Java Collection First first(Collection values)

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

Description

first

License

Open Source License

Declaration

public static Double first(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.List;

public class Main {
    public static Double first(Collection<Double> values) {
        List<Double> filteredValues = filterNulls(values);

        return filteredValues.size() > 0 ? filteredValues.get(0) : null;
    }//from  www.  j  a va  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. first(Collection collection)
  2. first(Collection items)
  3. first(Collection collection, E alternative)
  4. first(Collection collection)
  5. first(Collection collection)
  6. first(Collection collection)
  7. first(Collection self)
  8. first(Collection c)
  9. first(Collection c)