use of java8.util.function.LongPredicate in project streamsupport by stefan-zobel.
the class LongPrimitiveOpsTests method testForEach.
@Test(groups = { "serialization-hostile" })
public void testForEach() {
final long[] sum = new long[1];
LongStreams.range(1, 10).filter(new LongPredicate() {
@Override
public boolean test(long i) {
return i % 2 == 0;
}
}).forEach(new LongConsumer() {
@Override
public void accept(long i) {
sum[0] = sum[0] + i;
}
});
assertEquals(sum[0], 20);
}
Aggregations