Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Find max in a list of java classes using streams
static class Employee {
String firstName;
String surname;
double salary; //yeah, right!
}
public Optional<Employee> max(Collection<Employee> collection) {
return collection.stream().max((e1, e2) -> (int) Math.signum(e1.salary - e2.salary));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment