Why does Java8 Stream generate nothing?

You don’t have any terminal operation consuming your stream. So nothing happens. map() is an intermediate operation, which is not supposed to have side effects. What your code should be is

queue.stream().forEach(s-> {
    System.out.println("queue: "+ s);
});

Leave a Comment