Lambda Expressions in Java
Lambda expressions were added to Java more than 10 years ago. This course explains how you can write lambdas, how you can create your own and compose them, and how to use them to improve the readability of your code.
What you'll learn
Lambda expressions in Java are a classical tool that you can use to organize your applications and write better code. You can use them as is, but you can also go one step further and create your own. In this course, Lambda Expressions in Java, you will learn how to write lambdas and use them in your applications. First, you will explore how some APIs of the JDK have been built on lambda expressions, and how it brings better patterns of code that are more readable and easier to maintain. Then, you will see how the Java type system works for lambda expressions, how you can compose lambda expressions, and how you can write lambda expressions as method references. Finally, you will learn how to design your own lambda expressions by creating your own functional interfaces. When you are finished with this course, you will be able to write lambda expressions and method references easily, by just seeing the type of the lambda you need, and you will be able to refactor your existing code to leverage the level of quality that lambda expressions can give you.
Table of contents
- Introducing the Course and Its Agenda 2m
- Who Are You and What Do You Need to Know to Follow This Course 2m
- Defining the Types of Lambda Expressions 2m
- Defining Functional Interfaces 2m
- Using the @FunctionalInterface Annotation 2m
- Demo: Writing a Consumer to Print the Elements of a List 4m
- Demo: Using a Predicate to Filter the Content of a List 2m
- Demo: Writing a Supplier and Invoking Its Method 3m
- Demo: Using Functions to Map Objects to Other Objects 3m
- Util Function Package 1m
- Are Lambdas Objects? 3m
- Demo: Capturing External Values from a Lambda 5m
- Demo: Using Non-Denotable Types to Creates Immutable Wrappers 3m
- Module Wrap Up 1m
- Introducing the Module and its Agenda 2m
- Demo: Designing a OR Operation on Predicates 4m
- Demo: Implementing the OR Operation on Predicates 5m
- Demo: Designing and Implementing the AND Operation on Predicates 4m
- Demo: Protecting Your Lambdas Against Errors 1m
- Demo: Designing and Implementing the NOT Operator on Predicates 2m
- Demo: Analyzing the Predicate Interface from the JDK 1m
- Demo: Chaining Functions of the Same Type 4m
- Demo: Chaining Functions of Different Types in the Right Order 3m
- Demo: Composing Functions 3m
- Demo: Analyzing the Function Interface from the JDK 1m
- Demo: Failing Fast When Chaining Lambdas 6m
- Wrapping up the Use of Default and Static Methods With Lambdas 1m
- Demo: Working with the For Each Method of Iterable and Map 4m
- Demo: Chaining Consumers and BiConsumers 5m
- Module Wrap Up 1m
- Introducing the Module and Its Agenda 2m
- Writing Your First Method Reference 2m
- Calling Constructors and Methods with Method References 3m
- Examining the Four Types of Method References 4m
- Demo: Writing Method References Efficiently with Your IDE 6m
- Demo: Writing Array Constructors with Method References 1m
- Demo: Creating Method References on Your Own Interfaces 4m
- Module Wrap Up 2m
- Introducing the Module and its Agenda 2m
- Comparing Object Using Comparable and Comparators 3m
- Demo: Writing a First, Simple Comparator 4m
- Demo: Creating a Factory of Generic Comparators 3m
- Demo: Chaining Comparators Using Default Methods 4m
- Demo: Refactoring the Chaining of Comparators Using Functions 3m
- Demo: Creating a Natural Order Comparator 2m
- Demo: Reversing an Existing Comparator 3m
- Demo: Protecting Your Comparators against Null Values 4m
- Demo: Analyzing the Comparator Interface from the JDK 4m
- Module Wrap Up 2m
- Introducing the Module and Its Agenda 1m
- Demo: Reading the Example File Line by Line 2m
- Demo: Analyzing the Structure of the Data to Map It to Records 4m
- Demo: Handling Corrupted Lines and Bad Formats 4m
- Demo: Refactoring the Analysis of a Line of the File 4m
- Demo: Using Records and Lambda to Make Your Code Cleaner 3m
- Demo: Getting the Company with the Highest Revenue 2m
- Demo: Getting the Company with the Highest Cumulated Revenue 3m
- Demo: Making Your Code Meaningful with Records 5m
- Demo: Improving Readability with Factory Methods 4m
- Module Wrap Up 1m
- Course Wrap Up 3m