Lambda Expressions 101

When writing classes that implement functional interfaces, Java programmers found themselves
writing a lot of boilerplate code for objects that were only used once. In Java 8, Lambda
expressions were introduced as a way to concisely define an implementation of a functional
interface without explicitly declaring a new class. They served as “syntactic sugar” for explicit
and anonymous class instantiation, improving readability and code-writing at the cost of flexibility.

When to use each: