import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.impl.factory.Lists; import org.eclipse.collections.api.DoubleIterable; public class Main { public static void main(String[] args) { MutableList<Integer> numbers = Lists.mutable.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); DoubleIterable average = numbers.select(i -> i % 2 == 0).collectDouble(Integer::doubleValue).average(); System.out.println("Average of even numbers: " + average); } }


上一篇:
下一篇:
切换中文