Java 8 stream operation on empty list

collect is a terminal operation, so it must be evaluated.

When terminating a Stream pipeline with collect(Collectors.toList()), you’ll always get an output List (you’ll never get null). If the Stream is empty (and it doesn’t matter if it’s empty due to the source of the stream being empty, or due to all the elements of the stream being filtered out prior to the terminal operation), the output List will be empty too.

Leave a Comment

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