From 3169c324fbed103150d23a790da0f1c963571d44 Mon Sep 17 00:00:00 2001 From: SteffenLm <33038091+SteffenLm@users.noreply.github.com> Date: Wed, 23 Aug 2023 17:58:13 +0200 Subject: [PATCH 1/2] implement solution --- Exercise.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Exercise.java b/Exercise.java index 9dabbb2..89cbecc 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,21 @@ 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"); + } + }); + } } From f272820bf17b47c7075555a2be32291dfe971667 Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Wed, 23 Aug 2023 15:58:33 +0000 Subject: [PATCH 2/2] Google Java Format --- Exercise.java | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Exercise.java b/Exercise.java index 89cbecc..bac2e7e 100644 --- a/Exercise.java +++ b/Exercise.java @@ -16,20 +16,21 @@ public static void main(String[] args) { 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"); - } - }); + 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"); + } + }); } }