-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathExercise.java
More file actions
36 lines (32 loc) · 1.1 KB
/
Exercise.java
File metadata and controls
36 lines (32 loc) · 1.1 KB
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
35
36
import java.util.ArrayList;
import java.util.function.Consumer;
public class Exercise {
public static void main(String[] args) {
ArrayList<Student> students = new ArrayList<>();
students.add(new Student("Steffen", 28));
students.add(new Student("Marianna", 24));
students.add(new Student("Mirco", 26));
students.add(new Student("Dennis", 30));
students.add(new Student("Peter", 29));
students.add(new Student("Leander", 29));
students.add(new Student("Alu", 32));
students.add(new Student("Yannik", 28));
students.add(new Student("Hanni", 29));
students.add(new Student("Manu", 30));
students.forEach(
new Consumer<Student>() {
@Override
public void accept(Student student) {
if (student.age() > 26) {
System.out.println(student.name() + " ist " + student.age() + " Jahre alt");
}
}
});
students.forEach(
(student) -> {
if (student.age() > 26) {
System.out.println(student.name() + " ist " + student.age() + " Jahre alt");
}
});
}
}