import com.github.underscore.__;
public class Main {
public static void main(String[] args) {
Studnet[] students = {
new Student("Alice", 18, "A"),
new Student("Bob", 20, "B"),
new Student("Charlie", 19, "A")
};
int totalAge = __.chain(students)
.filter(s -> s.getAge() > 18)
.map(Student::getAge)
.reduce(0, (a, b) -> a + b);
System.out.println("Total age of students older than 18: " + totalAge);
}
}
<dependency>
<groupId>com.github.javadev</groupId>
<artifactId>underscore-java</artifactId>
<version>1.42</version>
</dependency>