System.out.println(f.factoril.ap

2023-04-02  本文已影响0人  哈迪斯Java

import java.util.function.Function;

public class Factoril {
Function<Long, Long> factoril = n -> {
long result = 1;
for (int i = 1; i <= n; i++) {
result *= i;
}
return result;
};

public static void main(String[] args) {
    Factoril f = new Factoril();
    System.out.println(f.factoril.apply((long) 11));
}

}
import java.util.List;
import java.util.stream.Collectors;

public class AvgAgeDemo {

public static void main(String[] args) {
    List<Employee> list = Employee.getEmpList(); // 获取公共类的测试数据
    double avgAge = list.stream().collect(Collectors.averagingDouble(Employee::getAge));
    list.stream().filter(people -> people.getAge() > avgAge).forEach(e -> System.out.println(e));
}

}

上一篇下一篇

猜你喜欢

热点阅读