LongStream.asSequence所在位置是kotlin.streams / java.util.stream.LongStream.asSequence,其相关用法介绍如下。

用法:

fun LongStream.asSequence(): Sequence<Long>

创建一个 Sequence 实例,该实例包装了遍历其元素的原始流。

例子:

import java.util.stream.*
import kotlin.streams.*

fun main(args: Array<String>) {
//sampleStart
val longStream: LongStream = LongStream.of(5_000_000_000, 6_000_000_000, 7_000_000_000)
val longSequence: Sequence<Long> = longStream.asSequence()
println(longSequence.joinToString(", ")) // 5000000000, 6000000000, 7000000000
//sampleEnd
}

输出:

5000000000, 6000000000, 7000000000