This method returns an infinite sequential unordered stream, where each element is generated by the provided DoubleSupplier
.
package com.logicbig.example.doublestream;
import java.util.stream.DoubleStream;
public class GenerateExample {
public static void main(String... args) {
DoubleStream.generate(Math::random)
.limit(5)
.forEach(System.out::println);
}
}
Output
0.6046935041178899
0.7443550768824858
0.43830092663111275
0.19260453064075833
0.2549137796555012