DoubleStream generate(DoubleSupplier s)
returns an infinite sequential unordered stream
generated by the provided DoubleSupplier.
generate
has the following syntax.
static DoubleStream generate(DoubleSupplier s)
The following example shows how to use generate
.
import java.util.Random; import java.util.stream.DoubleStream; import java.util.stream.Stream; /*w w w .j av a 2s. c o m*/ public class Main { public static void main(String[] args) { DoubleStream i = DoubleStream.generate(new Random()::nextDouble); Stream<Double> o = i.boxed(); o.limit(10).forEach(System.out::println); } }
The code above generates the following result.