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));
}
}
网友评论