Stay organized with collections
Save and categorize content based on your preferences.
DoubleStream.Builder
public
static
interface
DoubleStream.Builder
implements
DoubleConsumer
java.util.stream.DoubleStream.Builder
|
A mutable builder for a DoubleStream
.
A stream builder has a lifecycle, which starts in a building
phase, during which elements can be added, and then transitions to a built
phase, after which elements may not be added. The built phase
begins when the build()
method is called, which creates an
ordered stream whose elements are the elements that were added to the
stream builder, in the order they were added.
Summary
Public methods |
abstract
void
|
accept(double t)
Adds an element to the stream being built.
|
default
DoubleStream.Builder
|
add(double t)
Adds an element to the stream being built.
|
abstract
DoubleStream
|
build()
Builds the stream, transitioning this builder to the built state.
|
Public methods
accept
public abstract void accept (double t)
Adds an element to the stream being built.
Parameters |
t |
double : the input argument |
add
public DoubleStream.Builder add (double t)
Adds an element to the stream being built.
Implementation Requirements:
- The default implementation behaves as if:
accept(t)
return this;
Parameters |
t |
double : the element to add |
build
public abstract DoubleStream build ()
Builds the stream, transitioning this builder to the built state.
An IllegalStateException
is thrown if there are further
attempts to operate on the builder after it has entered the built
state.
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,["# DoubleStream.Builder\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nDoubleStream.Builder\n====================\n\n\n`\npublic\nstatic\n\n\ninterface\nDoubleStream.Builder\n`\n\n\n`\n\n\nimplements\n\n`[DoubleConsumer](/reference/java/util/function/DoubleConsumer)`\n\n\n`\n\n|---------------------------------------|\n| java.util.stream.DoubleStream.Builder |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nA mutable builder for a `DoubleStream`.\n\nA stream builder has a lifecycle, which starts in a building\nphase, during which elements can be added, and then transitions to a built\nphase, after which elements may not be added. The built phase\nbegins when the [build()](/reference/java/util/stream/DoubleStream.Builder#build()) method is called, which creates an\nordered stream whose elements are the elements that were added to the\nstream builder, in the order they were added. \n**See also:**\n\n- [DoubleStream.builder()](/reference/java/util/stream/DoubleStream#builder())\n\nSummary\n-------\n\n| ### Public methods ||\n|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[accept](/reference/java/util/stream/DoubleStream.Builder#accept(double))`(double t) ` Adds an element to the stream being built. |\n| ` default `[DoubleStream.Builder](/reference/java/util/stream/DoubleStream.Builder) | ` `[add](/reference/java/util/stream/DoubleStream.Builder#add(double))`(double t) ` Adds an element to the stream being built. |\n| ` abstract `[DoubleStream](/reference/java/util/stream/DoubleStream) | ` `[build](/reference/java/util/stream/DoubleStream.Builder#build())`() ` Builds the stream, transitioning this builder to the built state. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[java.util.function.DoubleConsumer](/reference/java/util/function/DoubleConsumer)` ` |---------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[accept](/reference/java/util/function/DoubleConsumer#accept(double))`(double value) ` Performs this operation on the given argument. | | ` default `[DoubleConsumer](/reference/java/util/function/DoubleConsumer) | ` `[andThen](/reference/java/util/function/DoubleConsumer#andThen(java.util.function.DoubleConsumer))`(`[DoubleConsumer](/reference/java/util/function/DoubleConsumer)` after) ` Returns a composed `DoubleConsumer` 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 (double t)\n```\n\nAdds an element to the stream being built.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----|-------------------------------------|\n| `t` | `double`: the input argument \u003cbr /\u003e |\n\n| Throws ||\n|---------------------------------------------------------------------|------------------------------------------------------------|\n| [IllegalStateException](/reference/java/lang/IllegalStateException) | if the builder has already transitioned to the built state |\n\n### add\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic DoubleStream.Builder add (double t)\n```\n\nAdds an element to the stream being built.\n\n\u003cbr /\u003e\n\n##### Implementation Requirements:\n\n- The default implementation behaves as if: \n\n accept(t)\n return this;\n \n| Parameters ||\n|-----|-------------------------------------|\n| `t` | `double`: the element to add \u003cbr /\u003e |\n\n| Returns ||\n|--------------------------------------------------------------------------|-----------------------|\n| [DoubleStream.Builder](/reference/java/util/stream/DoubleStream.Builder) | `this` builder \u003cbr /\u003e |\n\n| Throws ||\n|---------------------------------------------------------------------|------------------------------------------------------------|\n| [IllegalStateException](/reference/java/lang/IllegalStateException) | if the builder has already transitioned to the built state |\n\n### build\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract DoubleStream build ()\n```\n\nBuilds the stream, transitioning this builder to the built state.\nAn `IllegalStateException` is thrown if there are further\nattempts to operate on the builder after it has entered the built\nstate.\n\n\u003cbr /\u003e\n\n| Returns ||\n|----------------------------------------------------------|-------------------------|\n| [DoubleStream](/reference/java/util/stream/DoubleStream) | the built stream \u003cbr /\u003e |\n\n| Throws ||\n|---------------------------------------------------------------------|------------------------------------------------------------|\n| [IllegalStateException](/reference/java/lang/IllegalStateException) | if the builder has already transitioned to the built state |"]]