Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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