Java 8 has a limit thread method:
package com.concretepage.util.stream; import java.util.Arrays; import java.util.List; public class LimitDemo { public static void main(String[] args) { List<String> list = Arrays.asList("AA","BB","CC","DD","EE"); list.stream().limit(3).forEach(s->System.out.println(s)); } }
exit:
AA BB CC
What is the name of the analogue in Kotlin, or how to do it better in another way?
java-8 java-stream kotlin
Letfar
source share