how to find specific elements from a list in java

Solutions on MaxInterview for how to find specific elements from a list in java by the best coders in the world

showing results for - "how to find specific elements from a list in java"
Ilaria
24 Mar 2020
1public Customer findUsingEnhancedForLoop(
2  String name, List<Customer> customers) {
3
4    for (Customer customer : customers) {
5        if (customer.getName().equals(name)) {
6            return customer;
7        }
8    }
9    return null;
10}