Answers for "get max on stream java 8"

2

find max in stream java

employees.stream().max(comparator).get();
Posted by: Guest on May-21-2021
0

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));
Posted by: Guest on October-01-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language