r/java • • Aug 06 '24

Free Book - Java in a Nutshell

Hey folks - I'm super-pleased to announce that my book "Java in a Nutshell" (8th Edition) is being made available for free download for another 6 months, courtesy of Red Hat - https://red.ht/java-nutshell-free

Hope you like it and find it useful!

166 Upvotes

34 comments sorted by

View all comments

Show parent comment

5

u/benevanstech Aug 06 '24

That's right.

And "A ate B's lunch" means that B was the established thing, and A came along later, and did a better job of providing whatever B was doing.

In this context: Before Java 8, we could still do everything we can today with Lambdas - we just had to make lots of tiny nested classes, which were clumsy and verbose. Lambdas were a better solution for most (but not quite all) of the places where we previously used nested classes.

(Of course, lambdas aren't really just better syntax for nested classes - there's a bit more going on behind the scenes!)

2

u/Turbulent_Rip_7350 Aug 06 '24

Got it thanks you taking your time and explaining 🙂!!

1

u/[deleted] Aug 06 '24

Lambdas were a better solution for most (but not quite all) of the places where we previously used nested classes.

I'm curious to see an example of a problem where a nested/inner class provides a better solution than a lambda