Operations (methods)
Many methods of the Stream
interface, including those that have a functional interface type as a parameter, are called operations because they are not implemented as traditional methods. Their functionality is passed into a method as a function. The operations are just shells that call a method of the functional interface, assigned as the type of the parameter
method.
For example, let’s look at the Stream<T> filter (Predicate<T> predicate)
method. Its implementation is based on the call to the test(T t)
method Boolean of the Predicate<T>
function. So, instead of saying, we use the filter()
method of the Stream
object to select some of the stream elements and skip others, programmers prefer to say, we apply an operation filter that allows some of the stream elements to get through and skip others. It describes the nature of the action (operation), not the particular algorithm, which is unknown until the method receives a particular function...