February 2018
Intermediate to advanced
350 pages
7h 35m
English
Primitive streams were introduced in Java 8, to take advantage of primitive data types in Java while using Streams (again, Streams are basically from Java, and Kotlin just adds a few extension functions to the Streams API). IntStream, LongStream, and DoubleStream are part of those primitive Streams.
These primitive streams work similarly to the normal Stream with some added features of the primitive data types.
So, let's take an example; have a look at the following program:
fun main(args: Array<String>) {
val intStream = IntStream.range(1,10)
val result = intStream.sum()
println("The sum of elements is $result")
}
So, we created an IntStream value with the IntStream.range() function, the range function takes two integers ...
Read now
Unlock full access