Java Stream create from generator function

Description

Java Stream create from generator function


import java.util.Random;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) {
    Stream.generate(new Random()::nextInt)
    .limit(10)//w w w.  jav a2s .co  m
    .forEach(System.out::println);
  }
}



PreviousNext

Related