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