Stay organized with collections
Save and categorize content based on your preferences.
BiConsumer
public
interface
BiConsumer
java.util.function.BiConsumer<T, U>
|
Represents an operation that accepts two input arguments and returns no
result. This is the two-arity specialization of Consumer
.
Unlike most other functional interfaces, BiConsumer
is expected
to operate via side-effects.
This is a functional interface
whose functional method is accept(java.lang.Object, java.lang.Object)
.
Summary
Public methods |
abstract
void
|
accept(T t, U u)
Performs this operation on the given arguments.
|
default
BiConsumer<T, U>
|
andThen(BiConsumer<? super T, ? super U> after)
Returns a composed BiConsumer that performs, in sequence, this
operation followed by the after operation.
|
Public methods
accept
public abstract void accept (T t,
U u)
Performs this operation on the given arguments.
Parameters |
t |
T : the first input argument |
u |
U : the second input argument |
andThen
public BiConsumer<T, U> andThen (BiConsumer<? super T, ? super U> after)
Returns a composed BiConsumer
that performs, in sequence, this
operation followed by the after
operation. If performing either
operation throws an exception, it is relayed to the caller of the
composed operation. If performing this operation throws an exception,
the after
operation will not be performed.
Parameters |
after |
BiConsumer : the operation to perform after this operation |
Returns |
BiConsumer<T, U> |
a composed BiConsumer that performs in sequence this
operation followed by the after operation |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# BiConsumer\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nBiConsumer\n==========\n\n\n`\npublic\n\n\ninterface\nBiConsumer\n`\n\n\n`\n\n\n`\n\n|---------------------------------------|\n| java.util.function.BiConsumer\\\u003cT, U\\\u003e |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nRepresents an operation that accepts two input arguments and returns no\nresult. This is the two-arity specialization of [Consumer](/reference/java/util/function/Consumer).\nUnlike most other functional interfaces, `BiConsumer` is expected\nto operate via side-effects.\n\nThis is a [functional interface](/reference/java/util/function/package-summary)\nwhose functional method is [accept(java.lang.Object, java.lang.Object)](/reference/java/util/function/BiConsumer#accept(T,%20U)). \n**See also:**\n\n- [Consumer](/reference/java/util/function/Consumer)\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[accept](/reference/java/util/function/BiConsumer#accept(T,%20U))`(T t, U u) ` Performs this operation on the given arguments. |\n| ` default `[BiConsumer](/reference/java/util/function/BiConsumer)`\u003cT, U\u003e` | ` `[andThen](/reference/java/util/function/BiConsumer#andThen(java.util.function.BiConsumer\u003c?%20super%20T,?%20super%20U\u003e))`(`[BiConsumer](/reference/java/util/function/BiConsumer)`\u003c? super T, ? super U\u003e after) ` Returns a composed `BiConsumer` that performs, in sequence, this operation followed by the `after` operation. |\n\nPublic methods\n--------------\n\n### accept\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void accept (T t, \n U u)\n```\n\nPerforms this operation on the given arguments.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----|---------------------------------------|\n| `t` | `T`: the first input argument \u003cbr /\u003e |\n| `u` | `U`: the second input argument \u003cbr /\u003e |\n\n### andThen\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic BiConsumer\u003cT, U\u003e andThen (BiConsumer\u003c? super T, ? super U\u003e after)\n```\n\nReturns a composed `BiConsumer` that performs, in sequence, this\noperation followed by the `after` operation. If performing either\noperation throws an exception, it is relayed to the caller of the\ncomposed operation. If performing this operation throws an exception,\nthe `after` operation will not be performed.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|--------------------------------------------------------------------|\n| `after` | `BiConsumer`: the operation to perform after this operation \u003cbr /\u003e |\n\n| Returns ||\n|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|\n| [BiConsumer](/reference/java/util/function/BiConsumer)`\u003cT, U\u003e` | a composed `BiConsumer` that performs in sequence this operation followed by the `after` operation \u003cbr /\u003e |\n\n| Throws ||\n|-------------------------------------------------------------------|--------------------|\n| [NullPointerException](/reference/java/lang/NullPointerException) | if `after` is null |"]]