If you’re a developer with core Java SE skills, this hands-on book takes you through the language changes in Java 8 triggered by the addition of lambda expressions. You’ll learn through code examples, exercises, and fluid explanations how these anonymous functions will help you write simple, clean, library-level code that solves business problems.

Lambda expressions are a fairly simple change to Java, and the first part of the book shows you how to use them properly. Later chapters show you how lambda functions help you improve performance with parallelism, write simpler concurrent code, and model your domain more accurately, including building better DSLs.

Use exercises in each chapter to help you master lambda expressions in Java 8 quickly

Richard Warburton

Richard is an empirical technologist and solver of deep-dive technical problems. He has professionally worked on static analysis problems, verifying part of a compiler and developing advanced automated bug detection technology. More recently his career has been focussed on data analytics for high performance computing. He is a leader in the London Java Community, sits on their JCP Committee and organises the Adopt-a-JSR programs for Lambdas and Date and Time in Java 8. Richard is also a known conference speaker, having talked at JavaOne, DevoxxUK and JAX London. He obtained a PhD in Computer Science from The University of Warwick where his research focussed on compiler theory.

The animal on the cover of Java 8 Lambdas is a lesser spotted eagle (Aquila pomarina). This large bird of prey can be found in Eastern Europe and belongs to the family Accipitridae, like all typical eagles. The lesser spotted eagle is medium-sized with a head and bill that are small for eagles; these eagles typically measure up to 60 cm in length with a 150 cm wingspan.Juvenile spotted eagles have white spots on their flight feathers, also called remiges, whereas adults are pale brown in the head and wings with dark plumage. These eagles breed in central and eastern Europe, laying 1–3 white buff-spotted eggs in a tree nest. As is typical for eagles, the number of young depends on the amount of food during the breeding season. The female begins incubation when the first egg is laid; often the first young outgrows its clutchmate and eventually kills or eats them.The cover image is from Meyers Kleines. The cover fonts are URW Typewriter and Guardian Sans. The text font is Adobe Minion Pro; the heading font is Adobe Myriad Condensed; and the code font is Dalton Maag's Ubuntu Mono.

The book describes practical approach to new features introduced in Java 8. Most of the book is dedicated to Lambdas but the author also described other language and library add-ons.

The first two paragraphs contain introduction to Lambda expressions and explain why Java needs them. Third paragraph presents Stream's key concepts. All operations (like map, filter or flatMap) are explained using very descriptive examples. Fourth paragraph goes into the details of other Java 8 concepts like Optional, default/static methods in the interfaces and binary compatibility. After introducing those additional concepts the author goes into the details of collections and Collectors (starting from easy topics like element ordering and finishing on advanced like parallelism vs concurrency, debugging or refactoring). The last two paragraphs of the book describes architectural design patterns using Lambda expressions and shows some real life examples for topics like nonblocking I/O.

Writing style

Java 8 Lambdas is written using very easy to learn style. All concepts are briefly described theoretically and explained in detail using examples. There is also a GitHub repository with exercises for presented topics. The author focuses on practical approach for Java 8 features rather than theoretical aspects.

Conclusion and recommendation

Java 8 Lambdas is a must-have book for those who start using new features introduced in Java 8. The author clearly assumes basic understanding of previous Java features, so I wouldn't recommend this book for beginners. On the other hand an experienced programmer will feel comfortable with key concepts of Lambdas after reading less then forty pages (!!).

I highly recommend reading this book in two parts. At first, read basic concepts and get familiar with them (paragraphs 1-4). Do some exercises or ever better - get involved into some project which uses Java 8. Finally, finish reading the advanced topics of the book.

I spent 8 hours over the weekend struggling with the first 5 chapters of this book. Monday I found Rebel Labs has a free PDF, 'Java 8 Revealed'. The examples and style in Java 8 Revealed is far more helpful than Java 8 Lambdas.

For example, in Chapter 2 of Java 8 Lambdas, there is an explanation of functional interfaces as ActionListeners and examples in a table that explains Predicate as "Returns boolean" and gives example of "Has this album been released yet?". The Rebel Labs Java 8 Revealed PDF is clearer, stating "Predicate consumes an instance of type T as a parameter and produces boolean value". When I code I will be thinking of the latter explanation, not the former.

If you are interested in learning about the new features of Java 8 in particular Lambdas then this is the book for you!

It is excellently written, with wonderful easy to understand examples. The style is as if your friend has sat you down in the pub and is helping you understand something new.

There is also some sly humour in there - one of my favourite is when he is talking about multiple inheritance issues and has two interfaces Carriage and Jukebox that both implement a method rock() (obviously with different intents!)

I surprised myself by how quickly I finished this book (that's how easy to read it is!) But despite this, the author still manages to teach you all the facts and history necessary for you to have a full understanding of the subject.

I can't rate this book highly enough. I only wish that the author had written more books so that I could buy them all!

I was able to jump start using lambdas in Java 8 right after reading a chapter or two from this book and then gradually learned as I read forward.The book is very well-written, with concise and horizon-widening examples (e.g. BDD 'framework' was really interesting).

Loving Java and using it professionally I stumbled upon this book, and , oh boy, did it deliver. When I first wanted to learn Functional Programming I started to use Scala. But a lot of the books on Scala did not explain FP in a good way... at least for me. But this book explained the mechanics behind FP, not only the application in Java 8.

So now I understand Java 8 Lambdas, and FP in general. Because of this book.

In a nutshell: If you are looking for a concise and high-impact guide to the core features of Java 8, then you've found the right book! Whether you're just getting started with Java, or are a seasoned programmer, this book will help you get to grips with the new JDK 8 essentials such as Lambdas and Streams

I'm sure many people browsing this book will have heard about the recent (March '14) release of Java JDK 8 and all of the associated excitement about 'the biggest language changes' since JDK 5, and no doubt you are looking to see if any of the current JDK 8 books are worth an addition to your programming bookshelf. My answer to that question for this book is a definite yes.

The book starts with a whistle-stop tour of the influences for the new language additions, such as Lambdas and Streams (with a nod to the much-vaunted 'functional programming'), and then launches into explaining and demonstrating these key features in a well-paced and logical fashion. The stand-out chapters for me are 3, 4 and 5, in which you get to see many practical examples of where and how the new syntax (and new way of thinking) can save a lot of boilerplate typing and can also lead to much more expressive code.

As a relatively seasoned Java programmer, the examples and associated explanations had me up-and-running with the new features over the course of a weekend, and left me plenty of room (and motivation) to start experimenting in my own time with my new-found knowledge.

Data parallelism is covered well in Chapter 6, and the essential topic of testing (and a few associated gotchas with the new Lambda-driven approach) is covered nicely in the following chapter. Another excellent chapter is 'Design and Architectural Principles', which walks through some of the well-known design patterns and demonstrates to you that all of your current pattern knowledge doesn't have to be thrown away when using a functional style of coding. There is also a great section in this chapter discussing how the new language features relate to Uncle Bob's SOLID principles, and if you get chance I would also recommend searching for a companion talk by Richard on the Skillsmatter website.

Personally I think this book will end up alongside the classic Java books that I recommend to anyone looking to truly master the language, and this list includes such classics as 'Effective Java', 'Java Concurrency In Practice', 'Java Generics and Collections' and 'The Well-grounded Java Developer'. Richard has done a great job of distilling the key elements of the new JDK 8 language feature, and presented them in a concise tour-de-force without skimping on detail. A job well done!

Disclaimer: I know Richard personally from his good work within the London Java Community, and was also an (unpaid) reviewer for an early version of this book. I have attempted to write an unbiased review, and would be happy to discuss any of my thoughts listed here via personal communication. Anyone who has seen Richard present, or had the pleasure of pair-programming with him, will know he is very much the 'real deal' when it comes to Java wizardry, and so I whole-heartedly support his first foray into the world of publishing!

Like most Java developers who's been embedded in the world of Object Oriented development and design, the new world of functional programming presents learning challenge.

Thankfully this book doesn't derail the learning experience by trying to explain lambda calculus and category theory but instead takes you through a set of guided explanations that help transition your thinking from the Java of yesterday to the Java of today.

Within the first 5 chapters or so you'll be up and running with Lambdas and using them in the most common use case scenarios (manipulating collections). I was Map Reducing like a boss before I even knew it and I didn't care whether I really had a handle on the formal terminology or not.

I had the pleasure of doing a technical review for this book and Richard has done an excellent job.This is an ideal book for any Java developer looking to learn how to harness the power of Lambdas in their code.I would particularly recommend it for anyone with limited experience of functional programming and/or closures.