Java Reference
In-Depth Information
CHAPTER 6
Lambda Expressions
There are very few means by which a new feature in an existing language can have a
significant impact on the ecosystem. Lambda expressions for the Java language are one
such significant new feature that will have an effect on many facets of the ecosystem.
Simply defined, lambda expressions are a convenient way to create anonymous func-
tions. They provide an easy way to create a single method interface using an expression
or series of statements. Lambda expressions are built upon functional interfaces, which
are interfaces that contain a single abstract method. They can be applied in many differ-
ent contexts, ranging from simple anonymous functions to sorting and filtering Col-
lections . Moreover, lambda expressions can be assigned to variables and then passed
into other objects.
In this chapter, you will learn how to create lambda expressions, and you'll see
many examples of how they can be applied in common scenarios. You'll also learn how
to generate the building blocks for lambda expressions, so that you can construct applic-
ations to facilitate them. The chapter will delve into the java.util.function
package, which contains a bevy of useful functional interfaces that lambdas can imple-
ment. Lastly, you will see how to simplify certain types of lambda expressions into
method references for a more concise approach.
After reading this chapter, you to will be able to see the impact that lambda expres-
sions have on the Java language. They modernize the language by making developers
more productive, and opening new possibilities in many areas. Lambda expressions turn
the page on Java, bringing the language into a new light, with the likes of other lan-
guages that have had similar constructs for some time. Those languages helped to pave
the way for lambda expressions in the Java language, and there is no doubt that lambda
expressions will pave the way for many elegant solutions.
Search WWH ::




Custom Search