Here you can find the source of first(Collection
public static Double first(Collection<Double> values)
//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; } }