Uses of Interface java.util.function.UnaryOperator (Java Platform SE 8 )
Date: 2026-03-29

## Uses of Interface
java.util.function.UnaryOperator

- Packages that use UnaryOperator
  Package | Description
  --- | ---
  java.time.temporal | Access to date and time using fields and units, and date time adjusters.
  java.util | Contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).
  java.util.concurrent | Utility classes commonly useful in concurrent programming.
  java.util.concurrent.atomic | A small toolkit of classes that support lock-free thread-safe programming on single variables.
  java.util.function | Functional interfaces provide target types for lambda expressions and method references.
  java.util.stream | Classes to support functional-style operations on streams of elements, such as map-reduce transformations on collections.

- - ### Uses of UnaryOperator in java.time.temporal

    Methods in java.time.temporal with parameters of type UnaryOperator
    Modifier and Type | Method and Description
    --- | ---
    `static TemporalAdjuster` | TemporalAdjusters.`ofDateAdjuster(UnaryOperator<LocalDate> dateBasedAdjuster)` Obtains a `TemporalAdjuster` that wraps a date adjuster.

  - ### Uses of UnaryOperator in java.util

    Methods in java.util with parameters of type UnaryOperator
    Modifier and Type | Method and Description
    --- | ---
    `void` | Vector.`replaceAll(UnaryOperator<E> operator)`
    `void` | ArrayList.`replaceAll(UnaryOperator<E> operator)`
    `default void` | List.`replaceAll(UnaryOperator<E> operator)` Replaces each element of this list with the result of applying the operator to that element.

  - ### Uses of UnaryOperator in java.util.concurrent

    Methods in java.util.concurrent with parameters of type UnaryOperator
    Modifier and Type | Method and Description
    --- | ---
    `void` | CopyOnWriteArrayList.`replaceAll(UnaryOperator<E> operator)`

  - ### Uses of UnaryOperator in java.util.concurrent.atomic

    Methods in java.util.concurrent.atomic with parameters of type UnaryOperator
    Modifier and Type | Method and Description
    --- | ---
    `E` | AtomicReferenceArray.`getAndUpdate(int i, UnaryOperator<E> updateFunction)` Atomically updates the element at index `i` with the results of applying the given function, returning the previous value.
    `V` | AtomicReferenceFieldUpdater.`getAndUpdate(T obj, UnaryOperator<V> updateFunction)` Atomically updates the field of the given object managed by this updater with the results of applying the given function, returning the previous value.
    `V` | AtomicReference.`getAndUpdate(UnaryOperator<V> updateFunction)` Atomically updates the current value with the results of applying the given function, returning the previous value.
    `E` | AtomicReferenceArray.`updateAndGet(int i, UnaryOperator<E> updateFunction)` Atomically updates the element at index `i` with the results of applying the given function, returning the updated value.
    `V` | AtomicReferenceFieldUpdater.`updateAndGet(T obj, UnaryOperator<V> updateFunction)` Atomically updates the field of the given object managed by this updater with the results of applying the given function, returning the updated value.
    `V` | AtomicReference.`updateAndGet(UnaryOperator<V> updateFunction)` Atomically updates the current value with the results of applying the given function, returning the updated value.

  - ### Uses of UnaryOperator in java.util.function

    Methods in java.util.function that return UnaryOperator
    Modifier and Type | Method and Description
    --- | ---
    `static <T> UnaryOperator<T>` | UnaryOperator.`identity()` Returns a unary operator that always returns its input argument.

  - ### Uses of UnaryOperator in java.util.stream

    Methods in java.util.stream with parameters of type UnaryOperator
    Modifier and Type | Method and Description
    --- | ---
    `static <T> Stream<T>` | Stream.`iterate(T seed, UnaryOperator<T> f)` Returns an infinite sequential ordered `Stream` produced by iterative application of a function `f` to an initial element `seed`, producing a `Stream` consisting of `seed`, `f(seed)`, `f(f(seed))`, etc.

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.