BiConsumer
Stay organized with collections
Save and categorize content based on your preferences.
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(Object, Object)
.
Public Method Summary
abstract
void
|
accept(T t, U u)
Performs this operation on the given arguments.
|
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
public
abstract
void
accept
(T t, U u)
Performs this operation on the given arguments.
Parameters
t |
the first input argument |
u |
the second input argument
|
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 |
the operation to perform after this operation |
Returns
- a composed
BiConsumer
that performs in sequence this
operation followed by the after
operation
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-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 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eBiConsumer\u003c/code\u003e is a functional interface representing an operation that takes two inputs and returns no result, primarily working through side-effects.\u003c/p\u003e\n"],["\u003cp\u003eIt has a functional method \u003ccode\u003eaccept(Object, Object)\u003c/code\u003e which performs the operation on the provided arguments.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eBiConsumer\u003c/code\u003e includes an \u003ccode\u003eandThen\u003c/code\u003e method to chain operations, enabling the sequential execution of another \u003ccode\u003eBiConsumer\u003c/code\u003e after the current one.\u003c/p\u003e\n"]]],[],null,["# BiConsumer\n\npublic interface **BiConsumer** \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.html).\nUnlike most other functional interfaces, `BiConsumer` is expected\nto operate via side-effects.\n\nThis is a [functional interface](/j2objc/javadoc/jre/reference/java/util/function/package-summary)\nwhose functional method is [accept(Object, Object)](../../../../reference/java/util/function/BiConsumer.html#accept(T,%20U)). \n\n##### See Also\n\n- [Consumer](../../../../reference/java/util/function/Consumer.html) \n\n### Public Method Summary\n\n|--------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract void | [accept](../../../../reference/java/util/function/BiConsumer.html#accept(T,%20U))(T t, U u) Performs this operation on the given arguments. |\n| [BiConsumer](../../../../reference/java/util/function/BiConsumer.html)\\\u003cT, U\\\u003e | [andThen](../../../../reference/java/util/function/BiConsumer.html#andThen(java.util.function.BiConsumer\u003c?%20super%20T,%20?%20super%20U\u003e))([BiConsumer](../../../../reference/java/util/function/BiConsumer.html)\\\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#### public abstract void\n**accept**\n(T t, U u)\n\nPerforms this operation on the given arguments. \n\n##### Parameters\n\n| t | the first input argument |\n| u | the second input argument |\n|---|---------------------------|\n\n#### public [BiConsumer](../../../../reference/java/util/function/BiConsumer.html)\\\u003cT, U\\\u003e\n**andThen**\n([BiConsumer](../../../../reference/java/util/function/BiConsumer.html)\\\u003c? super T, ? super U\\\u003e after)\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##### Parameters\n\n| after | the operation to perform after this operation |\n|-------|-----------------------------------------------|\n\n##### Returns\n\n- a composed `BiConsumer` that performs in sequence this operation followed by the `after` operation \n\n##### Throws\n\n| [NullPointerException](../../../../reference/java/lang/NullPointerException.html) | if `after` is null |\n|-----------------------------------------------------------------------------------|--------------------|"]]