find max in stream java
employees.stream().max(comparator).get();
stream find max
class Person {
String name;
Integer age;
// standard constructors, getters and setters
}
We want to find the Person object with the minimum age:
Person alex = new Person("Alex", 23);
Person john = new Person("John", 40);
Person peter = new Person("Peter", 32);
List<Person> people = Arrays.asList(alex, john, peter);
// then
Person minByAge = people
.stream()
.min(Comparator.comparing(Person::getAge));
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us