Using the Java 8 &#x27;stream&#x27; API:<p><pre><code>   IntStream.iterate(0,  i -&gt; i + 1)
	.mapToObj( i -&gt; Collections.nCopies(i, i % 2 == 0) )
	.flatMap(Collection::stream)
	.limit(1000)
</code></pre>
Generate an infinite series of incrementing numbers, starting from 0, map each to a stream of boolean indicating true&#x2F;false, flatten that stream of streams, then limit the output.