February 2018
Intermediate to advanced
350 pages
7h 35m
English
The Stream Builder interface makes it really easy to create an instance of Stream with ease. Have a look at the following example:
fun main(args: Array<String>) {
val stream = Stream.builder<String>()
.add("Item 1")
.add("Item 2")
.add("Item 3")
.add("Item 4")
.add("Item 5")
.add("Item 6")
.add("Item 7")
.add("Item 8")
.add("Item 9")
.add("Item 10")
.build()
println("The Stream is ${stream.collect(Collectors.toList())}")
}
The output is as follows:

The Stream.builder() method returns an instance of Streams.Builder. Then, we used the Builder.add function; the add function accepts an item for the stream value to be built, and ...
Read now
Unlock full access