Question : java find item in list by property
Answered by : saverio-pangallo
Customer james = customers.stream()
.filter(customer -> "James".equals(customer.getName()))
.findAny()
.orElse(null);
Source : https://www.baeldung.com/find-list-element-java | Last Update : Wed, 26 Feb 20
Question : java 8 find in list by property
Answered by : 2-programmers-1-bug
Optional<Person> matchingObject = objects.stream(). filter(p -> p.email().equals("testemail")). findFirst();
Source : https://stackoverflow.com/questions/33992479/java-8-stream-api-to-find-unique-object-matching-a-property-value | Last Update : Thu, 12 Mar 20