There is a stream method limit
in Java 8:
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));
}
}
output:
AA
BB
CC
What is the name of analog in Kotlin, or how to do it better by another way?