DoubleStream builder() in Java with Examples
DoubleStream builder() returns a builder for a DoubleStream.
Syntax :
static DoubleStream.Builder builder()
Parameters :
- 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.
Return Value : The function returns a builder for a DoubleStream.
Example 1 :
// Java code for DoubleStream builder() import java.util.*; import java.util.stream.Stream; import java.util.stream.DoubleStream; class GFG { // Driver code public static void main(String[] args) { // Creating an DoubleStream using // DoubleStream builder() DoubleStream stream = DoubleStream.builder() .add(2.3) .build(); // Displaying the elements stream.forEach(System.out::println); } } |
chevron_right
filter_none
Output :
2.3
Example 2 :
// Java code for DoubleStream builder() import java.util.*; import java.util.stream.Stream; import java.util.stream.DoubleStream; class GFG { // Driver code public static void main(String[] args) { // Creating an DoubleStream using // DoubleStream builder() DoubleStream stream = DoubleStream.builder(). add(2.3).add(-1.2).add(3.5).add(10.74).build(); // Displaying the elements stream.forEach(System.out::println); } } |
chevron_right
filter_none
Output :
2.3 -1.2 3.5 10.74
Recommended Posts:
- DoubleStream.Builder add(double t) in Java with Examples
- DoubleStream.Builder build() in Java
- DoubleStream.Builder accept() method in Java
- DoubleStream min() in Java with examples
- DoubleStream max() in Java with examples
- Stream builder() in Java with Examples
- DoubleStream boxed() in Java with Examples
- DoubleStream limit() in Java with Examples
- DoubleStream anyMatch() in Java with examples
- DoubleStream allMatch() in Java with examples
- DoubleStream distinct() in Java with examples
- DoubleStream noneMatch() in Java with examples
- DoubleStream peek() in Java with examples
- DoubleStream count() in Java with examples
- DoubleStream empty() 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 contribute@geeksforgeeks.org. 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.



