mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-28 06:51:01 +07:00
14 lines
334 B
Java
14 lines
334 B
Java
// "Collapse loop with stream 'sum()'" "true-preview"
|
|
|
|
import java.util.List;
|
|
|
|
public class Main {
|
|
interface Person {
|
|
int getAge();
|
|
}
|
|
|
|
public long test(List<Person> collection) {
|
|
long i = collection.stream().filter(person -> person != null && person.getAge() >= 10).mapToLong(Person::getAge).sum();
|
|
return i;
|
|
}
|
|
} |