There is no nice way to convert given boolean[] foo
array into stream in Java-8 in one statement, or I am missing something?
(I
Given boolean[] foo
use
Stream stream = IntStream.range(0, foo.length)
.mapToObj(idx -> foo[idx]);
Note that every boolean value will be boxed, but it's usually not a big problem as boxing for boolean does not allocate additional memory (just uses one of predefined values - Boolean.TRUE
or Boolean.FALSE
).