API-Definition: http://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html,
Kommentar: Dave Hartveld http://blog.hartveld.com/2013/03/jdk-8-33-stream-api.html
List<Block> blocks = ...;
int sumOfWeights = 0; for (Block block : blocks) { if (block.getColor() == Color.RED) { sumOfWeights += block.getWeight(); } }
int sumOfWeights = blocks.stream() .filter(b -> b.getColor() == Color.RED) .map(b -> b.getWeight()).sum();