Stay organized with collections
Save and categorize content based on your preferences.
IntConsumer
public
interface
IntConsumer
java.util.function.IntConsumer
|
Known indirect subclasses
|
Represents an operation that accepts a single int
-valued argument and
returns no result. This is the primitive type specialization of
Consumer
for int
. Unlike most other functional interfaces,
IntConsumer
is expected to operate via side-effects.
This is a functional interface
whose functional method is accept(int)
.
Summary
Public methods |
abstract
void
|
accept(int value)
Performs this operation on the given argument.
|
default
IntConsumer
|
andThen(IntConsumer after)
Returns a composed IntConsumer that performs, in sequence, this
operation followed by the after operation.
|
Public methods
accept
public abstract void accept (int value)
Performs this operation on the given argument.
Parameters |
value |
int : the input argument |
andThen
public IntConsumer andThen (IntConsumer after)
Returns a composed IntConsumer
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 |
IntConsumer : the operation to perform after this operation |
Returns |
IntConsumer |
a composed IntConsumer 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.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# IntConsumer\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \n\nIntConsumer\n===========\n\n\n`\npublic\n\n\ninterface\nIntConsumer\n`\n\n\n`\n\n\n`\n\n|--------------------------------|\n| java.util.function.IntConsumer |\n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known indirect subclasses [IntStream.Builder](/reference/java/util/stream/IntStream.Builder), [IntSummaryStatistics](/reference/java/util/IntSummaryStatistics), [LongSummaryStatistics](/reference/java/util/LongSummaryStatistics) |---------------------------------------------------------------------|-------------------------------------------------------------------------------------| | [IntStream.Builder](/reference/java/util/stream/IntStream.Builder) | A mutable builder for an `IntStream`. | | [IntSummaryStatistics](/reference/java/util/IntSummaryStatistics) | A state object for collecting statistics such as count, min, max, sum, and average. | | [LongSummaryStatistics](/reference/java/util/LongSummaryStatistics) | A state object for collecting statistics such as count, min, max, sum, and average. | |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nRepresents an operation that accepts a single `int`-valued argument and\nreturns no result. This is the primitive type specialization of\n[Consumer](/reference/java/util/function/Consumer) for `int`. Unlike most other functional interfaces,\n`IntConsumer` is expected to operate via side-effects.\n\nThis is a [functional interface](/reference/java/util/function/package-summary)\nwhose functional method is [accept(int)](/reference/java/util/function/IntConsumer#accept(int)). \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/IntConsumer#accept(int))`(int value) ` Performs this operation on the given argument. |\n| ` default `[IntConsumer](/reference/java/util/function/IntConsumer) | ` `[andThen](/reference/java/util/function/IntConsumer#andThen(java.util.function.IntConsumer))`(`[IntConsumer](/reference/java/util/function/IntConsumer)` after) ` Returns a composed `IntConsumer` 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 (int value)\n```\n\nPerforms this operation on the given argument.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|----------------------------------|\n| `value` | `int`: the input argument \u003cbr /\u003e |\n\n### andThen\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic IntConsumer andThen (IntConsumer after)\n```\n\nReturns a composed `IntConsumer` 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` | `IntConsumer`: the operation to perform after this operation \u003cbr /\u003e |\n\n| Returns ||\n|----------------------------------------------------------|------------------------------------------------------------------------------------------------------------|\n| [IntConsumer](/reference/java/util/function/IntConsumer) | a composed `IntConsumer` 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 |"]]