3 ms·
Streams are a bit more general. They allow you to use functional operations on sequence of elements (e.g. map, filter, reduce, etc.) to build a processing pipel
by random3 8y ago
Streams are a bit more general. They allow you to use functional operations on sequence of elements (e.g. map, filter, reduce, etc.) to build a processing pipeline which can execute async and in parallel.
```
widgets.stream()
.filter(b -> b.getColor() == RED)
.mapToInt(b -> b.getWeight())
.sum();
```
https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html https://docs.oracle.com/javase/8/docs/api/java/util/stream/p...
They aren't specific to Java. In fact they require features such as lambdas that made them less practical until Java 8.