Stream builder() in Java with Examples Last Updated : 06 Dec, 2018 Comments Improve Suggest changes Like Article Like Report Stream builder() returns a builder for a Stream. Syntax : static <T> Stream.Builder<T> builder() where, T is the type of elements. Return Value : A stream builder. Example 1 : Java // Java code for Stream builder() import java.util.*; import java.util.stream.Stream; class GFG { // Driver code public static void main(String[] args) { // Using Stream builder() Stream.Builder<String> builder = Stream.builder(); // Adding elements in the stream of Strings Stream<String> stream = builder.add("Geeks").build(); // Displaying the elements in the stream stream.forEach(System.out::println); } } Output : Geeks Example 2 : Java // Java code for Stream builder() import java.util.*; import java.util.stream.Stream; class GFG { // Driver code public static void main(String[] args) { // Using Stream builder() Stream.Builder<String> builder = Stream.builder(); // Adding elements in the stream of Strings Stream<String> stream = builder.add("Geeks") .add("for") .add("Geeks") .add("GeeksQuiz") .build(); // Displaying the elements in the stream stream.forEach(System.out::println); } } Output : Geeks for Geeks GeeksQuiz Example 3 : Java // Java code for Stream builder() import java.util.*; import java.util.stream.Stream; import java.util.stream.Collectors; class GFG { // Driver code public static void main(String[] args) { // Using Stream builder() Stream.Builder<String> builder = Stream.builder(); // Adding elements in the stream of Strings Stream<String> stream = builder.add("GEEKS") .add("for") .add("Geeks") .add("GeEKSQuiz") .build(); // Converting elements to Lower Case // and storing them in List list List<String> list = stream.map(String::toLowerCase) .collect(Collectors.toList()); // Displaying the elements in list System.out.println(list); } } Output : [geeks, for, geeks, geeksquiz] Comment More infoAdvertise with us Next Article Stream builder() in Java with Examples S Sahil_Bansall Follow Improve Article Tags : Java Practice Tags : Java Similar Reads Stream empty() in Java with Examples Stream empty() creates an empty sequential Stream. Syntax : static <T> Stream<T> empty() Parameters : T : The type of stream elements. Stream : A sequence of objects that supports various methods which can be pipelined to produce the desired result. Return Value : Stream empty() returns 1 min read BitSet stream() Method in Java with Examples The stream() method of Java BitSet class is used to return a stream of indices for every bit contained in the BitSet. The indices are returned in increasing order. The size of the stream is the number of bits in the set state of the BitSet, which is equal to the value returned by the cardinality() m 2 min read LongStream count() in Java with examples LongStream count() returns the count of elements in the stream. LongStream count() is present in java.util.stream.LongStream Syntax : long count() Example 1 : Count the elements in LongStream. Java // Java code for LongStream count() // to count the number of elements in // given stream import java. 2 min read Stream filter() in Java with examples Stream filter(Predicate predicate) returns a stream consisting of the elements of this stream that match the given predicate. This is an intermediate operation. These operations are always lazy i.e, executing an intermediate operation such as filter() does not actually perform any filtering, but ins 3 min read Stream.of(T t) in Java with examples Stream of(T t) returns a sequential Stream containing a single element i.e, a singleton sequential stream. A sequential stream work just like for-loop using a single core. On the other hand, a Parallel stream divide the provided task into many and run them in different threads, utilizing multiple co 2 min read Like