Java 17 Recipes


Download 3.2 Mb.
Pdf ko'rish
bet112/245
Sana02.06.2024
Hajmi3.2 Mb.
#1839910
1   ...   108   109   110   111   112   113   114   115   ...   245
Bog'liq
Java 17 Recipes

5-15. Summary
Java is an object-oriented language. To harness the capabilities of the language, you must 
learn how to become proficient with object-orientation. This chapter covered basics 
such as class creation and access modifiers. It also covered encapsulation, interfaces
and recipes to help developers take advantage of the power of object-orientation.
Chapter 5 ObjeCt-Oriented java


207
© Josh Juneau, Luciano Manelli 2022 
J. Juneau and L. Manelli, Java 17 Recipes
https://doi.org/10.1007/978-1-4842-7963-2_6
CHAPTER 6
Lambda Expressions
A convenient way to create anonymous functions is using the lambda expressions 
using an expression or series of statements. Lambda expressions are built on 
functional interfaces, which contain a single abstract method, and that method has no 
implementation.
They can be applied in many contexts, ranging from simple anonymous functions 
to sorting and filtering collections. Moreover, lambda expressions can be assigned to 
variables and then passed into other objects.
In this chapter, you 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 
applications to facilitate their use. After reading this chapter, you can see the impact of 
lambda expressions on the Java language. They modernize the language by allowing 
developers to be more productive and opening new possibilities in many areas. Lambda 
expressions turned the page on Java, bringing the language into a new light, with the 
likes of other languages that have had similar constructs for some time. Those languages 
helped pave the way for lambda expressions in the Java language. There is no doubt that 
lambda expressions continue to pave the way for many elegant solutions.
Note The functional interface was introduced in Java 8. It is an Interface that 
contains exactly one abstract method (i.e., any interface with one abstract method 
is a functional interface). Moreover, it’s recommended that a functional interface 
has an informative @FunctionalInterface annotation.


208

Download 3.2 Mb.

Do'stlaringiz bilan baham:
1   ...   108   109   110   111   112   113   114   115   ...   245




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling