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.

What's New in Java 8: Lambdas

An in-depth look at the new features of Java 8

4.0
(89 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.

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.

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

Functional Interfaces

05:14

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.

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

Method & Constructor References

12:32

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!

Scope & Effectively Final

08:08

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

Exception Handling

11:55

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

Lambdas vs Closures

07:17

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

Invocation & Bytecode (invokedynamic vs invokestatic)

14:17

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

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.