There are only two ways of using a lambda expression: by assigning the result to a variable, or by returning the result from a method.
You should take your time to go through the documentation of all the methods of the
Stream,
IntStream,
Comparator and
Collectors classes. They provide a very rich toolbox that you should become familiar with if you want to solve problems in a functional way.