SerialToParallel { public static int sumOfSquares(IntStream range) { return range.parallel() .map(x -> x * x) .sum(); }  static int sumOfSquares(IntStream range); static int sequentialSumOfSquares(IntStream range);  }
@Test public void testSerialToParallel() { IntStream range = IntStream.range(0, 100); assertEquals(328350, SerialToParallel.sumOfSquares(range)); }