Java Reference
In-Depth Information
As the program illustrates, because all three lambda expressions are compatible with
test( ) , all can be executed through a NumericTest reference. In fact, there is no need to
use three separate NumericTest reference variables because the same one could have been
used for all three tests. For example, you could create the variable myTest and then use it
to refer to each test, in turn, as shown here:
Of course, using different reference variables called isFactor , lessThan , and absEqual , as
the original program does, makes it very clear to which lambda expression each variable
refers.
There is one other point of interest in the preceding program. Notice how the two para-
meters are specified for the lambda expressions. For example, here is the one that determ-
ines if one number is a factor of another:
Search WWH ::




Custom Search