Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/java/util/stream/LongStream.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/util/stream/LongStream.Builder#inhmethods)

# LongStream.Builder

` public static interface LongStream.Builder `   
` implements https://developer.android.com/reference/java/util/function/LongConsumer `

|---|
| java.util.stream.LongStream.Builder |

<br />

*** ** * ** ***

A mutable builder for a `LongStream`.

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 begins when the `https://developer.android.com/reference/java/util/stream/LongStream.Builder#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.
**See also:**

- `https://developer.android.com/reference/java/util/stream/LongStream#builder()`

## Summary

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/java/util/stream/LongStream.Builder#accept(long)(long t) ` Adds an element to the stream being built. |
| ` default https://developer.android.com/reference/java/util/stream/LongStream.Builder` | ` https://developer.android.com/reference/java/util/stream/LongStream.Builder#add(long)(long t) ` Adds an element to the stream being built. |
| ` abstract https://developer.android.com/reference/java/util/stream/LongStream` | ` https://developer.android.com/reference/java/util/stream/LongStream.Builder#build()() ` Builds the stream, transitioning this builder to the built state. |

### Inherited methods

From interface ` https://developer.android.com/reference/java/util/function/LongConsumer ` ` abstract void` ` https://developer.android.com/reference/java/util/function/LongConsumer#accept(long)(long value) `

Performs this operation on the given argument.
` default https://developer.android.com/reference/java/util/function/LongConsumer` ` https://developer.android.com/reference/java/util/function/LongConsumer#andThen(java.util.function.LongConsumer)(https://developer.android.com/reference/java/util/function/LongConsumer after) `

Returns a composed `LongConsumer` that performs, in sequence, this operation followed by the `after` operation.

## Public methods

### accept

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void accept (long t)
```

Adds an element to the stream being built.

<br />

| Parameters ||
|---|---|
| `t` | `long`: the input argument <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the builder has already transitioned to the built state |

### add

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public LongStream.Builder add (long t)
```

Adds an element to the stream being built.

<br />

##### Implementation Requirements:

- The default implementation behaves as if:

      accept(t)
          return this;

| Parameters ||
|---|---|
| `t` | `long`: the element to add <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/stream/LongStream.Builder` | `this` builder <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the builder has already transitioned to the built state |

### build

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract LongStream 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.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/stream/LongStream` | the built stream <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the builder has already transitioned to the built state |