Effective Java! Perfer Lambdas to Anonymous Classes
This new chapter brings us to a new section on some newer Java features, lambdas and streams. I’m a big fan of lambdas and I think it has been a great addition to the Java language. I use lambdas everyday in my development and it definitely makes my code much clearer.
Before lambdas, interfaces and sometimes abstract classes with a single method would be used as function types. Implementations of these instances would be created via anonymous inner classes and allow a form of functional programming in your Java code. Let’s look at an example: