Find value in list with commons collections4

This page describes how to search for a property in a list and return the first match without examining the entire list.

Below an example on how this could be done:

Create a list of user objects by invoking the below method:

Use a predicate to search for an User object with the property ‘firstName3’. When a match is found it will return the match without going through the entire list:

When a match is found print it:

Sources: find-value-in-list-with-commons-collections4

Leave a Reply

Your email address will not be published. Required fields are marked *