thhh
04/27/2021, 4:51 PMCasey Brooks
04/27/2021, 5:13 PMStream until API 24. You could compile an app against higher SDK versions and use those APIs on devices running Android 7.0 or higher, but on older Android phones those APIs did not exist and would crash. However, now with desugaring, this is not a problem, and you can use many of the Java 8 APIs on older devices (notably LocalDate, Stream, and Optional). This fact has nothing to do with Kotlin at all.
However, in the Kotlin world, there’s really no need for Streams. The stdlib contains the same operations available on Stream directly on Collections without that intermediate Stream layer. Much of what was done with Stream was in fact just processing collections with a functional API (using .map, .filter, etc). In addition, the API of Stream is designed to be used from Java, which does not have extension functions, and so is a bit cumbersome to use from Kotlin.
For the less-common use-case of Streams, where you are actually generating and producing a lazy (potentially infinite) stream of data, Kotlin Sequences are basically a complete replacement. They are implemented very differently and are not directly compatible with one another, but you can easily convert a Stream into a Sequence to make it easier to consume in Kotlin, with stream.asSequence()