Last active
December 15, 2015 03:59
-
-
Save dlhartveld/5198093 to your computer and use it in GitHub Desktop.
Iterating (for-loop) version of the Stream API example. See also: https://gist.github.com/dlhartveld/5198058
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Block> blocks = /* ... */; | |
int sumOfWeights = 0; | |
for (Block block : blocks) { | |
if (block.getColor() == Color.RED) { | |
sumOfWeights += block.getWeight(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment