1class Person {
2 String name;
3 Integer age;
4
5 // standard constructors, getters and setters
6}
7We want to find the Person object with the minimum age:
8
9Person alex = new Person("Alex", 23);
10Person john = new Person("John", 40);
11Person peter = new Person("Peter", 32);
12List<Person> people = Arrays.asList(alex, john, peter);
13
14// then
15Person minByAge = people
16.stream()
17.min(Comparator.comparing(Person::getAge));
18