© Ralph Lecessi 2019
Ralph LecessiFunctional Interfaces in Javahttps://doi.org/10.1007/978-1-4842-4278-0_5

5. Operators

Ralph Lecessi1 
(1)
Kendall Park, NJ, USA
 

When a Function object’s input type is the same as its output type, an Operator interface can be used in place of a Function. Operator interfaces define a single type parameter.

Section 5.1: The UnaryOperator Interface

UnaryOperator is a functional interface with one type parameter such that UnaryOperator<T> inherits Function<T, T>. Like Function, a lambda expression that represents the apply method with a single argument must be provided. UnaryOperator supports andThen, compose, and identity as well. It is useful for implementing operations on a single operand.
@FunctionalInterface
public ...

Get Functional Interfaces in Java: Fundamentals and Examples now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.