Java's Lambda Expressions with built in and custom-built functional interfaces

Опубликовано: 04 Август 2026
на канале: Merlin Wellington
253
10

Java's lambda expressions are a powerful tool that let you pass code snippets into methods which can make a method much more generally usable. However, they have a weird syntax! They are essentially syntactic sugar that simplifies coding an anonymous class when the class you are extending is a functional interface (which means it has only one method that subclasses have to build). I'll lead you through an example which will help derive that funny syntax so that you understand exactly what it's doing. Then I'll go over the functional interfaces in java.util.function which simplify development of code that needs to pass code snippets around. And, finally, I'll show you how you can develop your own functional interfaces if Java's don't work for a given situation


In this video I'll walk you through:
An example that motivates using functional interfaces in our design
Three ways of coding the call on a method that has a functional interface as a parameter ending with lambda expressions
The list functional interfaces provided by java.util.function
How to build and use your own functional interfaces

TIMESTAMPS
0:00 Introduction
0:33 Why we want lambda expressions
1:08 Using java.util.function.Predicate as a parameter
1:43 Explicitly implementing Predicate
2:23 Using an anonymous class
3:37 Using a lambda expressions to code the anonymous class
5:07 Java's functional interfaces
7:51 Building our own functional interface
8:44 Conclusion

ABOUT MY CHANNEL
My channel is about good software engineering practices. We cover introductions to programming in C and Java. But I also have lots of software and computer engineering topics like PIC programming, advanced programming techniques, and things that distinguish good code from code that works.

Check out my channel here:
   / @wizardcraftcode  

Don’t forget to subscribe!

CHECK OUT MY OTHER VIDEOS:

C Programming Playlist:    • Coding in C  
Intro to Java Playlist:    • Introduction to Java Programming based on ...  
Software Engineering Topics Playlist:    • General Software Engineering Topics