diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 0000000..bfbeb0d --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,3 @@ +{ + "image": "mcr.microsoft.com/devcontainers/java:21" +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..add4f4e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "vscjava.vscode-java-pack" + ] +} \ No newline at end of file diff --git a/Exercise.java b/Exercise.java index 9dabbb2..bac2e7e 100644 --- a/Exercise.java +++ b/Exercise.java @@ -1,4 +1,5 @@ import java.util.ArrayList; +import java.util.function.Consumer; public class Exercise { @@ -14,5 +15,22 @@ public static void main(String[] args) { students.add(new Student("Yannik", 28)); students.add(new Student("Hanni", 29)); students.add(new Student("Manu", 30)); + + students.forEach( + new Consumer() { + @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"); + } + }); } }