forked from Rapter1990/JavaStreamAPIExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBiConsumerExample.java
More file actions
34 lines (23 loc) · 962 Bytes
/
BiConsumerExample.java
File metadata and controls
34 lines (23 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package functionalexamples;
import studentdata.Student;
import studentdata.StudentDataBase;
import java.util.List;
import java.util.function.BiConsumer;
public class BiConsumerExample {
public static void main(String[] args) {
nameAndActivities();
}
public static void nameAndActivities(){
BiConsumer<String, List<String>> studentBiConsumer = (name, activities) -> System.out.println(name + " : " + activities);
List<Student> students = StudentDataBase.getAllStudents();
students.forEach((s) -> studentBiConsumer.accept(s.getName(),s.getActivities()));
/*
Tomas : [swimming, basketball, volleyball]
Emily : [swimming, gymnastics, soccer]
Janet : [swimming, gymnastics, aerobics]
Dave : [swimming, gymnastics, soccer]
Sophie : [swimming, dancing, football]
James : [swimming, basketball, baseball, football]
*/
}
}