DoubleStream.Builder add(double t) is used to insert an element into the element in the building phase of stream. It adds an element to the stream being built.
default DoubleStream.Builder add(double t)
Parameters: This method accepts a mandatory parameter t which is the element to input into the stream.
Exceptions: This method throws IllegalStateException: when the builder has already transitioned to the built state. It means that the stream has entered the built phase and now no it can’t be changed. Hence no more elements can be added into the stream.
Below are the examples to illustrate add() method:
Stream successfully built 4.4 5.84 6.0 7.47
Example 2: To illustrate IllegalStateException
Stream successfully built 4.7 5.9 6.0 7.785 Exception thrown when now adding element into the stream: java.lang.IllegalStateException
- Java.util.LinkedList.poll(), pollFirst(), pollLast() with examples in Java
- Java.util.Collections.rotate() Method in Java with Examples
- Java lang.Long.byteValue() method in Java with Examples
- Java.util.concurrent.Phaser class in Java with Examples
- Java.lang.Short toString() method in Java with Examples
- Java lang.Long.lowestOneBit() method in Java with Examples
- Java lang.Long.numberOfTrailingZeros() method in Java with Examples
- Java lang.Long.highestOneBit() method in Java with Examples
- Java lang.Long.numberOfLeadingZeros() method in Java with Examples
- Java.util.concurrent.RecursiveAction class in Java with Examples
- Java.util.function.LongPredicate interface in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
- Java.util.concurrent.RecursiveTask class in Java with Examples
- Java.util.function.BiPredicate interface in Java with Examples
- Java.util.function.DoublePredicate interface in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.