Java tutorial
import java.util.stream.LongStream; public class Main { public static void main(String... args) { Accumulator accumulator = new Accumulator(); LongStream.rangeClosed(1, 100).forEach(accumulator::add); System.out.println(accumulator.total); } } class Accumulator { long total = 0; public void add(long value) { total += value; } }