How do you create stream of Boolean.FALSE, say, length of 100?
What I've struggled with is:
- Originally I've intended to create an array of
Boolean.FALSE. Butnew Boolean[100]returns an array ofNULL. So reasonably I considered to use stream API as a convenientIterableand almost (1)Iterablemanipulation tool; - There is no
Booleanno-params constructor (2), hence I can't useStream.generate(), since it acceptsSupplier<T>(3).
What I found is Stream.iterate(Boolean.FALSE, bool -> Boolean.FALSE).limit(100); gives what I want, but it doesn't seem to be quite elegant solution, IMHO.
One more option, I found (4) is IntStream.range(0, 100).mapToObj(idx -> Boolean.FALSE);, which seems to me even more strange.
Despite these options don't violate pipeline conception of a stream API, are there any more concise ways to create stream of Boolean.FALSE?