Java Reference
In-Depth Information
13 . What is < > ?
The diamond operator.
14 . How can the following be simplified?
It can be simplified by use of the diamond operator as shown here:
Chapter 14: Lambda Expressions and Method References
1 . What is the lambda operator?
The lambda operator is -> .
2 . What is a functional interface?
A functional interface is an interface that contains one and only one abstract method.
3 . How do functional interfaces and lambda expressions relate?
A lambda expression provides the implementation for the abstract method defined by
the functional interface. The functional interface defines the target type.
4 . What are the two general types of lambda expressions?
The two types of lambda expressions are expression lambdas and block lambdas. An
expression lambda specifies a single expression, whose value is returned by the
lambda. A block lambda contains a block of code. Its value is specified by a return
statement.
5 . Show a lambda expression that returns true if a number is between 10 and 20, inclus-
ive.
6 . Create a functional interface that can support the lambda expression you created in
question 5. Call the interface MyTest and its abstract method testing( ) .
7 . Create a block lambda that computes the factorial of an integer value. Demonstrate its
use. Use NumericFunc , shown in this chapter, for the functional interface.
Search WWH ::




Custom Search