Generate int from IntSupplier for IntStream
Description
The following code shows how to generate int from IntSupplier for IntStream.
Example
/* w ww.jav a 2 s. co m*/
import java.util.function.IntSupplier;
import java.util.stream.IntStream;
public class Main {
public static void main(String[] args) {
IntStream.generate(new IntSupplier(){
public int getAsInt(){
return 2;
}
}).limit(5)
.forEach(System.out::println);
}
}
The code above generates the following result.