Java SE API
UnaryOperator<T>
Specializes Function for operations whose input and output share the same type.
Formal Syntax & Structure
java syntaxjava
interface UnaryOperator<T> extends Function<T,T>Working Example
Example Snippetjava
import java.util.*;import java.util.function.*;public class Main {
public static void main(String[] args) { IntUnaryOperator addFee = cents -> cents + 25; UnaryOperator<String> prefix = s -> "#" + s; BinaryOperator<Integer> chooseLarger = (a, b) -> Math.max(a, b); System.out.println(addFee.applyAsInt(100)); System.out.println(prefix.apply("A7")); System.out.println(chooseLarger.apply(3, 8)); }}