Skip to content

Instantly share code, notes, and snippets.

Last active April 1, 2017 01:06
What would you like to do?
Find elements, map and extract in java using streams
public Optional<Double> findExtractAndMax(Collection<Employee> collection, String name) {
return -> e.firstName.equals(name)).map(e -> e.salary).max((a, b) -> (int) Math.signum(a - b));
double sal = findExtractAndMax(collection, "Bob");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment