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

- Packages that use Consumer
  Package | Description
  --- | ---
  java.lang | Provides classes that are fundamental to the design of the Java programming language.
  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.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 Consumer in java.lang

    Methods in java.lang with parameters of type Consumer
    Modifier and Type | Method and Description
    --- | ---
    `default void` | Iterable.`forEach(Consumer<? super T> action)` Performs the given action for each element of the `Iterable` until all elements have been processed or the action throws an exception.

  - ### Uses of Consumer in java.util

    Methods in java.util with parameters of type Consumer
    Modifier and Type | Method and Description
    --- | ---
    `void` | ArrayList.`forEach(Consumer<? super E> action)`
    `void` | Vector.`forEach(Consumer<? super E> action)`
    `default void` | PrimitiveIterator.OfDouble.`forEachRemaining(Consumer<? super Double> action)` Performs the given action for each remaining element until all elements have been processed or the action throws an exception.
    `default void` | Spliterator.OfDouble.`forEachRemaining(Consumer<? super Double> action)` Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception.
    `default void` | Iterator.`forEachRemaining(Consumer<? super E> action)` Performs the given action for each remaining element until all elements have been processed or the action throws an exception.
    `default void` | PrimitiveIterator.OfInt.`forEachRemaining(Consumer<? super Integer> action)` Performs the given action for each remaining element until all elements have been processed or the action throws an exception.
    `default void` | Spliterator.OfInt.`forEachRemaining(Consumer<? super Integer> action)` Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception.
    `default void` | PrimitiveIterator.OfLong.`forEachRemaining(Consumer<? super Long> action)` Performs the given action for each remaining element until all elements have been processed or the action throws an exception.
    `default void` | Spliterator.OfLong.`forEachRemaining(Consumer<? super Long> action)` Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception.
    `default void` | Spliterator.`forEachRemaining(Consumer<? super T> action)` Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception.
    `void` | Optional.`ifPresent(Consumer<? super T> consumer)` If a value is present, invoke the specified consumer with the value, otherwise do nothing.
    `default boolean` | Spliterator.OfDouble.`tryAdvance(Consumer<? super Double> action)` If a remaining element exists, performs the given action on it, returning `true`; else returns `false`.
    `default boolean` | Spliterator.OfInt.`tryAdvance(Consumer<? super Integer> action)` If a remaining element exists, performs the given action on it, returning `true`; else returns `false`.
    `default boolean` | Spliterator.OfLong.`tryAdvance(Consumer<? super Long> action)` If a remaining element exists, performs the given action on it, returning `true`; else returns `false`.
    `boolean` | Spliterator.`tryAdvance(Consumer<? super T> action)` If a remaining element exists, performs the given action on it, returning `true`; else returns `false`.

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

    Methods in java.util.concurrent with parameters of type Consumer
    Modifier and Type | Method and Description
    --- | ---
    `CompletableFuture<Void>` | CompletableFuture.`acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)`
    `CompletionStage<Void>` | CompletionStage.`acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)` Returns a new CompletionStage that, when either this or the other given stage complete normally, is executed with the corresponding result as argument to the supplied action.
    `CompletableFuture<Void>` | CompletableFuture.`acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)`
    `CompletionStage<Void>` | CompletionStage.`acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)` Returns a new CompletionStage that, when either this or the other given stage complete normally, is executed using this stage's default asynchronous execution facility, with the corresponding result as argument to the supplied action.
    `CompletableFuture<Void>` | CompletableFuture.`acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor)`
    `CompletionStage<Void>` | CompletionStage.`acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor)` Returns a new CompletionStage that, when either this or the other given stage complete normally, is executed using the supplied executor, with the corresponding result as argument to the supplied function.
    `void` | CopyOnWriteArrayList.`forEach(Consumer<? super E> action)`
    `void` | CopyOnWriteArraySet.`forEach(Consumer<? super E> action)`
    `void` | ConcurrentHashMap.KeySetView.`forEach(Consumer<? super K> action)`
    `<U> void` | ConcurrentHashMap.`forEach(long parallelismThreshold, BiFunction<? super K,? super V,? extends U> transformer, Consumer<? super U> action)` Performs the given action for each non-null transformation of each (key, value).
    `void` | ConcurrentHashMap.`forEachEntry(long parallelismThreshold, Consumer<? super Map.Entry<K,V>> action)` Performs the given action for each entry.
    `<U> void` | ConcurrentHashMap.`forEachEntry(long parallelismThreshold, Function<Map.Entry<K,V>,? extends U> transformer, Consumer<? super U> action)` Performs the given action for each non-null transformation of each entry.
    `void` | ConcurrentHashMap.`forEachKey(long parallelismThreshold, Consumer<? super K> action)` Performs the given action for each key.
    `<U> void` | ConcurrentHashMap.`forEachKey(long parallelismThreshold, Function<? super K,? extends U> transformer, Consumer<? super U> action)` Performs the given action for each non-null transformation of each key.
    `void` | ConcurrentHashMap.`forEachValue(long parallelismThreshold, Consumer<? super V> action)` Performs the given action for each value.
    `<U> void` | ConcurrentHashMap.`forEachValue(long parallelismThreshold, Function<? super V,? extends U> transformer, Consumer<? super U> action)` Performs the given action for each non-null transformation of each value.
    `CompletableFuture<Void>` | CompletableFuture.`thenAccept(Consumer<? super T> action)`
    `CompletionStage<Void>` | CompletionStage.`thenAccept(Consumer<? super T> action)` Returns a new CompletionStage that, when this stage completes normally, is executed with this stage's result as the argument to the supplied action.
    `CompletableFuture<Void>` | CompletableFuture.`thenAcceptAsync(Consumer<? super T> action)`
    `CompletionStage<Void>` | CompletionStage.`thenAcceptAsync(Consumer<? super T> action)` Returns a new CompletionStage that, when this stage completes normally, is executed using this stage's default asynchronous execution facility, with this stage's result as the argument to the supplied action.
    `CompletableFuture<Void>` | CompletableFuture.`thenAcceptAsync(Consumer<? super T> action, Executor executor)`
    `CompletionStage<Void>` | CompletionStage.`thenAcceptAsync(Consumer<? super T> action, Executor executor)` Returns a new CompletionStage that, when this stage completes normally, is executed using the supplied Executor, with this stage's result as the argument to the supplied action.

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

    Methods in java.util.function that return Consumer
    Modifier and Type | Method and Description
    --- | ---
    `default Consumer<T>` | Consumer.`andThen(Consumer<? super T> after)` Returns a composed `Consumer` that performs, in sequence, this operation followed by the `after` operation.

    Methods in java.util.function with parameters of type Consumer
    Modifier and Type | Method and Description
    --- | ---
    `default Consumer<T>` | Consumer.`andThen(Consumer<? super T> after)` Returns a composed `Consumer` that performs, in sequence, this operation followed by the `after` operation.

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

    Subinterfaces of Consumer in java.util.stream
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `Stream.Builder<T>` A mutable builder for a `Stream`.

    Methods in java.util.stream with parameters of type Consumer
    Modifier and Type | Method and Description
    --- | ---
    `void` | Stream.`forEach(Consumer<? super T> action)` Performs an action for each element of this stream.
    `void` | Stream.`forEachOrdered(Consumer<? super T> action)` Performs an action for each element of this stream, in the encounter order of the stream if the stream has a defined encounter order.
    `Stream<T>` | Stream.`peek(Consumer<? super T> action)` Returns a stream consisting of the elements of this stream, additionally performing the provided action on each element as elements are consumed from the resulting stream.

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, 2018, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.