AKCIA! CELOŽIVOTNÉ predplatné so zľavou 50%, nezmeškaj to!
Zisti viac
public List<Person> getAllAdultsImperative(List<Person> people) { List<Person> adults = new ArrayList<>(); for (Person person : people) { if (person.getAge() >= 18) { adults.add(person); } } return adults; }
public List<Person> getAllAdultsFunctional(List<Person> people) { return people.stream().filter(person -> person.getAge() >= 18).toList(); }