What's New in Java 8: Lambdas

An in-depth look at the new features of Java 8
4.3 (56 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
1,401 students enrolled
70% off
Take This Course
  • Lectures 19
  • Length 2 hours
  • Skill Level All Levels
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works


Find online courses made by experts from around the world.


Take your courses with you and learn anywhere, anytime.


Learn and practice real-world skills and achieve your goals.

About This Course

Published 5/2014 English

Course Description

This is PART 1 of a two part course looking at the new features of Java 8.

In this part, we take an in-depth look at lambdas and their supporting features; things like functional interfaces and type inference. In the follow up course (PART 2), we look at the remaining features.

After watching this course, you'll

  • Have an overview of new features in Java 8
  • Understand lambdas in-depth, their background, syntax, implementation details and how and when to use them
  • Understand the difference between functions to classes and why that's relevant to lambdas
  • Understand the difference between lambdas and closures
  • Appreciate the improvements to type inference that drive a lot of the new features
  • Be able to use method references and understand scoping and "effectively final"
  • Understand the differences in bytecode produced when using lambdas
  • Be able to reason about exceptions and exception handling best practice when using lambdasvariables

So whether you're migrating existing Java programs to Java 8 or building applications from scratch, this course will help you start to leverage the power of functional programming on the Java platform.

What are the requirements?

  • Previous experience with Java (pre Java-8)
  • An IDE to practice and experiment with the examples
  • Java Software Development Kit (SDK) available FREE from Oracle

What am I going to get from this course?

  • A FREE companion eBook to support your study
  • Get an overview of (almost) all of the new features in Java 8
  • Gain in-depth understanding of the major new features in Java 8 that you can apply straight away

Who is the target audience?

  • Anyone interested in learning about Java 8
  • Prior knowledge and experience of pre Java-8 is advantagous

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.


Section 1: Introduction

Welcome to the course.


A whistle-stop tour of the new features.

00:00 Introduction

00:42 Run down of the new features


The course comes with a free companion eBook.

Please register your course at http://bit.ly/whatsnewjava8 for updates to the book and to be notified of special offers on related courses.

00:00 Download your FREE companion eBook

00:15 Register for updates

Section 2: Introduction to Lambdas

A quick summary of what we'll be covering in this section.


This lecture talks about some background to functional programming and lambdas in general.

00:00 Background

00:15 Alonzo Church and the lambda calculus

01:00 John McCarthy and LISP

01:30 Lambda calculus and LISP expressions side by side

01:55 What is a lambda?


Anonymous functions (aka lambdas) are not the same thing as anonymous classes in Java.

Although we might start to use them in a similar way, there are several technical differences. Find out about these before we look at Java 8's syntax.

00:00 Lambdas aren't the same as anonymous classes

00:34 Summary

01:15 Lambdas aren't just syntactic sugar


Discover the basic syntax of lambdas in Java. We look at variations on the new syntax and how to put together a lambda.

Get up and running quickly and see how to convert legacy code to using the new syntax.

00:00 Introduction and Comparator example

01:15 Converting anonymous classes to lambdas

02:40 Syntax summary

7 questions

Test your knowledge on Lambdas.

Section 3: Lambdas In-depth

A quick summary of what we'll be covering in this section.


In this lecture, we talk about functional interfaces.

Functional interfaces are just regular Java interfaces but with just one method. Because Java understands the options for using these are limited (they only have one method), it can do all kinds of neat things. The most significant of which is using lambdas in-lieu of anonymous implementations of the interface.

00:00 What is a functional interface? SAM?

00:50 Examples of using the functional interface annotation

04:00 Summary


Recap the basics of type inference and learn about Java 8's improvements. We cover "target" typing as well as looking at the Java Enhancement Proposal (JEP) 101 covering generalised target typing.

00:00 Introducing the changes due to type inference with Java 8

00:22 Recapping the basics of type inference

01:45 Type erasure

02:52 The three areas of improvement

03:10 Target typing for lambdas

04:45 Parameter type inference in method calls

06:00 Parameter type inference for chained methods


Find out how to pass around references to exsitings methods using method references.

We take a look at the variations on syntax and show how you might use each.

00:00 What is a method reference?

01:08 What can you do with them?

03:35 The four types of method reference

04:03 Constructor method references (includes constructor arguments)

09:25 Static method references

10:00 Instance method references (of a particular object)

10:50 Instance method references (of an arbitrary object)

11:47 Summary of syntax


Lambdas are lexically scoped in Java 8. In this lecture, find out more about scoping and the new effectively final concept.

00:00 Scoping introduction

00:34 Lexical scoping demo

02:34 Effectively final introduction

03:15 Effectively final demo

07:35 Warning! Be more functional. Use fold/reduce instead!


Let's take a look at the options with dealing with exception from lambdas. We'll look at it from the perspective of the developer writing lambdas and from the perspective of the library developer, calling lambdas passed in.

00:00 Introducing the issues

02:12 Exception handling from the author's perspective

08:09 Exception handling from the client's perspective

11:35 Side by side comparison


The term closures and lambdas are often used interchangeably but just as often incorrectly. There are key differences between the two and in this lecture we'll take a look at what they are.

00:00 Introduction and Java timeline

01:25 What's the difference?

05:09 Side by side comparison

06:05 Summary


Take a look at the differences in bytecode between anonymous classes and the new lambdas.

00:00 Introduction

00:30 Recap on bytecode basics

01:55 Java as a stack based computation model

03:50 JVM "descriptors" ie, Ljava/lang/String;

05:57 Introducing the examples

06:20 Anonymous class

07:50 Anonymous class closing over variables (closure)

08:29 Lambda with no arguments

10:46 Lambda with arguments

12:20 Lambda closing over variables (closure)

13:04 Summary

20 pages

The source and corresponding bytecode for the examples from the previous lecture.

13 questions

Now really test your understanding of lambdas in Java.

Section 4: Java 7 Recap
Java 7 Article originally printed by Jaxenter
27 pages

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Toby Weston, Independent Software Developer

I specialise in modern software development; functional and object-oriented programming, agile and lean best practice. I wrote the book Essential Acceptance Testing and have written for magazines as well as regularly blogging.

I've been part of the software industry for more than fifteen years and love what I do. I love talking and writing about it and sharing my experiences online with Udemy.

Ready to start learning?
Take This Course