Created
September 19, 2022 16:17
-
-
Save benweidig/17cf23ea515041b23ef3a153b43de24e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Customer> customers = ...; | |
// Lambdas | |
customers.stream() | |
.filter(customer -> customer.isActive()) | |
.map(customer -> customer.getName()) | |
.map(name -> name.toUpperCase()) | |
.peek(name -> System.out.println(name)) | |
.toArray(count -> new String[count]); | |
// Method References | |
customers.stream() | |
.filter(Customer::isActive) | |
.map(Customer::getName) | |
.map(String::toUpperCase) | |
.peek(System.out::println) | |
.toArray(String[]::new); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment