Java-8: boolean primitive array to stream?

Given boolean[] foo use

Stream<Boolean> 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).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)