Geek Culture
Published in

Geek Culture

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:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kyle Carter

Kyle Carter

I'm a software architect that has a passion for software design and sharing with those around me.