When we use methods like filter, mapToInt, sum, etc. and
pass them lambda expressions I don't understand if the operations
are method themselves or are the lambda that we pass.
I' d like to know the correct terminology.
I think that the lambda is the function and thus the operation that we pass to methods that use that to produce a results.
Why is also said that filter, sum, etc. are operations that use function as
their arguments?
Are both correct terminology?
Both the Stream methods and the lambda arguments that they accept are, broadly speaking, operations. This isn't confusing once we get used to the idea that the arguments to method calls can be functions. A Stream method applies the function that it's been given to the values in its stream, either to produce a new stream (intermediate methods) or to produce some aggregated result (terminal methods).
For a more detailed explanation, see http://www.lambdafaq.org/why-are-lambda-expressions-being-added-to-java/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With