IntStream builder() in Java
IntStream builder() returns a builder for an IntStream.
Syntax :
static IntStream.Builder builder()
Parameters :
- IntStream.Builder : A mutable builder for an IntStream. 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 an IntStream.
Example 1 :
// Java code for IntStream builder() import java.util.*; import java.util.stream.Stream; import java.util.stream.IntStream; class GFG { // Driver code public static void main(String[] args) { // Creating an IntStream using // IntStream builder() IntStream stream = IntStream.builder().add(-1).build(); // Displaying the elements stream.forEach(System.out::println); } } |
chevron_right
filter_none
Output :
-1
Example 2 :
// Java code for IntStream builder() import java.util.*; import java.util.stream.Stream; import java.util.stream.IntStream; class GFG { // Driver code public static void main(String[] args) { // Creating an IntStream using // IntStream builder() IntStream stream = IntStream.builder() .add(-1).add(0).add(2).add(4).add(7).build(); // Displaying the elements stream.forEach(System.out::println); } } |
chevron_right
filter_none
Output :
-1 0 2 4 7
Recommended Posts:
- IntStream.Builder add() method in Java
- IntStream.Builder build() in Java with Examples
- IntStream.Builder accept() method in Java
- LongStream builder() in Java
- Builder Pattern in java
- Stream.Builder add() method in Java
- Stream.Builder build() in Java
- DoubleStream.Builder build() in Java
- LongStream.Builder add(long t) in Java
- LongStream.Builder build() in Java
- DoubleStream builder() in Java with Examples
- Stream builder() in Java with Examples
- Stream.Builder accept() method in Java
- DoubleStream.Builder accept() method in Java
- DoubleStream.Builder add(double t) 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.



