I need more clarification about lambda expression. How 'p' represents List<Person> people? Could you explain clear to me
List<Person> people = new ArrayList<>();
people.add(new Person("Mohamed", 69));
people.add(new Person("Doaa", 25));
people.add(new Person("Malik", 6));
Predicate<Person> pred = (p) -> p.getAge() > 65;
                No, p is not a List<Person> but a Person.
Predicate<Person> pred = p -> p.getAge() > 65;
This lambda expression declares 1 formal parameter and returns a boolean. As such, it can be represented as a Predicate (because the Predicate interface has a single functional method with this exact signature, called test). The type of p will be determined by the type of the Predicate you are creating.
For example, in the following code, p will be a List<Person>:
Predicate<List<Person>> predicate = p -> p.isEmpty();
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With