diff --git a/src/main/java/practice/StreamPractice.java b/src/main/java/practice/StreamPractice.java index 0a4c03562..e09ed8399 100644 --- a/src/main/java/practice/StreamPractice.java +++ b/src/main/java/practice/StreamPractice.java @@ -47,7 +47,7 @@ public List selectMenByAge(List peopleList, int fromAge, int toA .filter(person -> person.getSex().equals(Person.Sex.MAN) && fromAge <= person.getAge() && toAge >= person.getAge()) - .collect(Collectors.toList()); + .toList(); } public List getWorkablePeople(int fromAge, int femaleToAge, @@ -57,7 +57,7 @@ public List getWorkablePeople(int fromAge, int femaleToAge, || (person.getSex().equals(Person.Sex.MAN) && maleToAge >= person.getAge())); return peopleList.stream() .filter(workableFilter) - .collect(Collectors.toList()); + .toList(); } public List getCatsNames(List peopleList, int femaleAge) { @@ -65,7 +65,7 @@ public List getCatsNames(List peopleList, int femaleAge) { .filter(person -> person.getSex().equals(Person.Sex.WOMAN) && person.getAge() >= femaleAge) .flatMap(person -> person.getCats().stream().map(Cat::getName)) - .collect(Collectors.toList()); + .toList(); } public List validateCandidates(List candidates) {