IntStream generate(IntSupplier s) returns an infinite sequential unordered stream where each element is generated by the provided IntSupplier(a supplier of int-valued results). This is suitable for generating constant streams, streams of random elements, etc.
static IntStream generate(IntSupplier s)
- IntStream : a sequence of primitive int-valued elements.
- IntSupplier : a supplier of int-valued elements.
- s : IntSupplier for generated elements.
Return Value : a new infinite sequential unordered IntStream.
Example 1 : To generate stream of random integer.
4247 6827 2676 9129 3360 8718 7925
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.