streams

Why and How to Use Java.util.stream.Collectors

Streams are a wonderful feature in Java allowing you to write clean, efficient and powerful code. If you haven’t consumed the output of the stream, you will probably want to collect it. That’s when the methods from Java.util.stream.Collectors come to help. Here are some useful examples: Collect to list: We start with a list of… read more »

Reducing Streams in Java

Java 8 introduced streams, among other things, and one of my favourite features is the reduce() method. It combines a stream into a single method. Before Java 8 and streams, such a reduction had to be done with a loop like this: Now with Streams and reduce() it can be done as follows with a… read more »

Sidebar