Creating 3 sublists based on unique conditions I have written the following code for one of my requirements. Kindly help me if I can write this logic in a better.

public class PersonService {
    public PersonCategorized getCategorizedPerson(List&lt;Person&gt; allPersonFromDb) {
        List&lt;Person&gt; adultList = allPersonFromDb.stream().filter(PersonUtil::isAdult).collect(Collectors.toList());
        List&lt;Person&gt; underAgedList = allPersonFromDb.stream().filter(PersonUtil::isUnderAged).collect(Collectors.toList());
        List&lt;Person&gt; seniorCitizenList = allPersonFromDb.stream().filter(PersonUtil::isSeniorCitizen).collect(Collectors.toList());

        return new PersonCategorized(underAgedList, adultList, seniorCitizenList);
    }
}

public class PersonCategorized {
    private List&lt;Person&gt; underAgedPersonList;
    private List&lt;Person&gt; adultList;
    private List&lt;Person&gt; seniorCitizenList;

    public PersonCategorized(List&lt;Person&gt; underAgedPersonList, List&lt;Person&gt; adultList, List&lt;Person&gt; seniorCitizenList) {
        this.underAgedPersonList = underAgedPersonList;
        this.adultList = adultList;
        this.seniorCitizenList = seniorCitizenList;
    }

    public List&lt;Person&gt; getAdultList() {
        return adultList;
    }

    public List&lt;Person&gt; getSeniorCitizenList() {
        return seniorCitizenList;
    }

    public List&lt;Person&gt; getUnderAgedPersonList() {
        return underAgedPersonList;
    }
}

public class Person {
    private int age;
    private String name;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public int getAge() {
        return age;
    }

    public String getName() {
        return name;
    }
}

public class PersonUtil {
    public static boolean isAdult(Person person) {
        return person.getAge() &gt;= 18 &amp;&amp; person.getAge() &lt; 60;
    }

    public static boolean isUnderAged(Person person) {
        return person.getAge() &gt;= 0 &amp;&amp; person.getAge() &lt; 18;
    }

    public static boolean isSeniorCitizen(Person person) {
        return person.getAge() &gt;= 0 &amp;&amp; person.getAge() &lt; 18;
    }
}


One observation I had after posting here is I am iterating over the list 3 times to collect 3 different lists.
No much room for improvement here. The code is clear, readable, maintainable, short and nice. You could get rid of the three iterations by using a loop and filling three lists all in one iteration, but you'd sacrifice maintainability for a few microseconds saved. Don't do this unless you are in a real critical spot. For real world applications, keep it as it is.

One thing however is the PersonUtil. From an OO perspective, the Person should probably know whether it is underaged or senior or whatever and contain that business logic itself, so that you don't have to resort to a util-class. However, if the Person is an entity, eventually generated, you basically have no other choice.