mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-02 05:50:53 +07:00
15 lines
327 B
Java
15 lines
327 B
Java
// "Collapse loop with stream 'sum()'" "true-preview"
|
|
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
|
|
public class Main {
|
|
interface Person {
|
|
int getAge();
|
|
}
|
|
|
|
public long test(List<Person> collection) {
|
|
long i = collection.stream().filter(Objects::nonNull).mapToLong(Person::getAge).sum();
|
|
return i;
|
|
}
|
|
} |