A curated list of some of the best resources to learn Java 8 Programming like lambda expression, method references etc.
While the term “lambda expression” may sound abstract and academic, Java 8 Lambdas can have a big impact on how you program every day. Java 8 has not only introduced Lambda expressions but also Stream API, Functional interfaces, new Date and Time API and default methods, which has completely changed the way you write your Java code.
As a professional Java developer, you will have to learn Java 8 one day, and it’s better to do sooner than later.
Even if you are not using many of the Java 8 features, one thing is sure that It’s definitely changed change how you use Collection framework classes e.g. ArrayList or HashMap in your Java program, especially for high-performance applications.
Not surprisingly, I have also learned Java 8 new features and I am grateful to all these peoples, who have shared wonderful tutorials on lambdas and other Java 8 concepts.
These are the people who have mostly downloaded nightly builds, work through specification and the initial draft to create, easy to understand Java 8 tutorials and examples. Since I am personally following them, it makes a lot of sense for me to share all these resources with you guys, my readers.
Earlier, when I shared some differences between Java and Scala, I had mentioned about some cool features of Scala, which makes code concise, clear and more readable but Java 8 is brought parity on that as well.
So stay tuned and follow these Java 8 Lambdas, Stream API, and functional interfaces tutorial to get a feel of, what is going to be the biggest change in Java programming language since it’s the first launch; probably even bigger than Generics from Java 1.5.
What is Lambda expression in Java
In simplest terms, a lambda expression is a function — a bit of code — that you can pass to another method as an argument. Thus, you can cope with changing requirements by using a behavior, represented by a lambda, as a parameter.
One part of Java API, which is going to substantial change is the famous and probably most used Java Collection Framework, which is being reworked to use Stream API. Java 8’s functional programming features, like lambdas and the new Stream API, will provide a cleaner way to iterate through collections.
They are also going to help you write concise, maintainable code that scales easily and performs well on multicore architectures. If you are interested to learn more about lambda expression then the What’s New in Java 8: Lambdas is a great course which provides an in-depth look at the new features of Java 8.
Some of the best Java 8 Tutorials
As I said, I have started learning Java 8 new features to get myself ready to adopt Java 8 as soon as possible. I have a gut feeling that industry will probably do the same and once Java 8 will be formally released, there will be hardly a new project going to Java 1.6 or 7.
Much like what happened after Generics was introduced, now you won’t see any Collection framework code without Generics. There are lots of good Java 8 tutorials already available online, and I am going to make full use of those.
I have selected some of the best Java 8 tutorials to start with. This list is by no means complete and I will keep adding content on it, as and when I found something interesting and progress in my learning.
Whenever I talk about lambda expression of Java 8, this is the first resource, which comes to my mind. I have visited his lambda FAQ site a lot of times and it’s just amazing. If you don’t remember Maurice Naftalin is one of the authors of one of the great book Java Generics and Collection.
He has done an absolute gem of work to jolt down lambda expression FAQ, before going anywhere else, I strongly recommend to visit this site and go through those fundamental questions on Lambda expression.
Just to give you a sneak peek of what you are going to get, here are some questions from his Lambda FAQ:
- What is a lambda expression?
- Why are lambda expressions being added to Java?
- What is a functional interface? (answer)
- Are lambda expressions objects?
- Where can lambda expressions be used?
- What are the scoping rules for lambda expressions?
- What is the type of a lambda expression? (answer)
- Can lambda expressions be used to define recursive functions?
- Can lambda expressions use variables from their environment?
- What are the method references? (answer)
- What is the syntax, for instance, method references? (answer)
- What are constructor references?
I think Maurice is also working on a new edition of Java Collections and Generics to include Java 8 changes, which will be a truly great resource to start with. Eagerly waiting for that edition.
This is another great tutorial on lambda expression. Like all other official Java tutorial, this one is also up to mark. It starts with a naive approach to use traditional Java coding style and it improves upon its approach with local and anonymous classes and then finishes with an efficient and concise approach using lambda expressions.
It also explains what is method reference in Java 8 and how to use them. Since you use lambda expressions to create anonymous methods, remember not anonymous class. Sometimes, however, a lambda expression does nothing but call an existing method. In those cases, it’s often clearer to refer to the existing method by name.
Method references enable you to do this; they are compact, easy-to-read lambda expressions for methods that already have a name. The double colon operator (::) is used to denote method reference.
For all starters, once you finished reading Maurice’s lambda expression FAQ, you can start with this one. You will learn by doing comparative analysis opportunity presented by examples.
For example, to print the contents of a List, you can simply write
You can further check out the Complete Java MasterClass to learn more about method reference and lambda expression in Java 8.
3. Java 8 Lambda Expression Presentations and Video tutorial
There are lots of presentation on Java 8 new features, lambda expressions, stream API, functional interfaces, default methods, how lambda expression works, pros and cons of using lambda expression and a whole range of Java 8 topics.
I have collected some of the best ones which are delivered by the authority like Brian Goetz, Java Language Architect at Oracle, and main author of concurrency classic, Java Concurrency in Practice.
His presentation, Lambda: A Peek Under the Hood gives a wealth of technical detail on the implementation of lambda expression in Java. The Road to Lambda is another presentation by Brian Goetz, which provides a deep and comprehensive view of Project Lambda.
Here are some of the best presentations and online courses to learn Java 8
Another good presentation is from JavaZone,, September 2012: Lambdas in Java 8 By Angelika Langer, who talked about lambda expressions, functional types, extension methods, and method references
4) Adopt OpenJDK Lambda Tutorial
This is another set of exercises to teach the use of Java 8 lambda syntax, and the new Streams API. It contains proper instruction for doing this exercise hosted on Github, and some handy tutorials to setting up IDEs like Eclipse and IntelliJ for Java 8 lambda expression on Ubuntu, Mac OS, and Windows.
It also contains some good exercise on internal vs external iteration (the forEach method), Filtering and Collecting, Mapping and Method References.
You can download and install Java 8 to run these tutorials and examples. They will also run on higher Java version like Java 9 and Java 10 and Java 11 version.
This is one more collection of simple Java 8 tutorials on lambda expression. I like there easy to follow the example on a day to day topics.
They have Java 8 tutorials divided into the following topics :
- Introduction — The basics.
- Comparator — Using a comparator. (example)
- Collections Filtering — Filtering a collection. (example)
- Functions as Parameters — Passing functions as parameters (example.
- Listeners — Using lambdas as listeners. (example)
- Map/Reduce — Using map/reduce with Java 8 (example).
- DRY — DRY (Don’t Repeat Yourself). (example)
I would say very handy tutorial for busy Java developers who like to get their hands dirty by trying stuff.
6) IDE Support for Java 8 Lambda Expression
All three major Java IDEs e.g. Eclipse, IntelliJ, and Netbeans have support for the new Java 8 features including lambda expression, which is great for development and learning.
You can use these IDES to quickly get up-to-speed with new Java 8 features. Most of them provide context suggestion and automatically convert Anonymous class to lambda expression and method references wherever possible.
The NetBeans IDE also supports Java 8 and you can check out http://wiki.netbeans.org/JDK8 for more information on Netbeans support of Java 8.
Java 8 Books
Here are a couple of good books to learn Java 8. All these books focus on what, why and how of new features introduced in Java. The first two are my favorite and I strongly suggest Java developers read them.
1. Java 8 Lambdas in Action
Java 8 Lambdas in Action is probably the best book to learn Java 8 features. It’s one of the clearly-written guides to Java 8 lambdas and functional programming in Java.
It begins with a practical introduction to the structure and benefits of lambda expressions in real-world Java code.
The book then introduces the Stream API and shows how it can make the collections-related code radically easier to understand and maintain.
Along the way, you’ll discover new functional programming oriented design patterns with Java 8 for code reuse, code readability, exception handling, data manipulation, and concurrency.
For developers also exploring other functional languages on the JVM, the book concludes with a quick survey of useful functional features in Scala and Clojure. The good thing is that — the First chapter of Java 8 Lambdas in Action is FREE, and you can download to take a sneak peek of it.
2. Java SE 8 for the Really Impatient by Cay Horstmann (Jan 27, 2014)
This is another great book to learn new features of Java 8. It’s clear, concise and full of non-trivial examples, which makes learning really fun.
That’s all folks, It’s more than enough resources to learn key features of Java 8, mainly lambda expression, Stream API and functional interfaces.
Google is your best friend, so when you feel stuck, you can always do a quick search and I am sure you will find something, which solves your problem, that’s the biggest advantage of being part of this wonderful Java community.
Good luck and Enjoy learning Java 8 lambda expression.
Related Java 8 Tutorials
If you are interested in learning more about new features of Java 8, here are my earlier articles covering some of the important concepts of Java 8:
- 20 Examples of Date and Time in Java 8 (tutorial)
- How to use Stream class in Java 8 (tutorial)
- How to use filter() method in Java 8 (tutorial)
- How to use forEach() method in Java 8 (example)
- How to join String in Java 8 (example)
- How to convert List to Map in Java 8 (solution)
- How to use peek() method in Java 8 (example)
- How to convert the stream to the array in Java 8 (tutorial)
- Java 8 Certification FAQ (guide)
- Java 8 Mock Exams and Practice Test (test)
Thanks for reading this article so far. If you like these Java 8 resources then please share with your friends and colleagues. If you have any questions or feedback then please drop a note.