public final class DifferenceOfSquaresCalculator {

  public int computeSquareOfSumTo(int num) {
    int sum = 0;
    for (int i = 0; i <= num; i++) {
      sum += i;
    }
    return (int) Math.pow(sum, 2);
  }

  public int computeSumOfSquaresTo(int num) {
    int sum = 0;
    for (int i = 0; i <= num; i++) {
      sum += (int) Math.pow(i, 2);
    }
    return sum;
  }

  public int computeDifferenceOfSquares(int num) {
    int squareOfSum = computeSquareOfSumTo(num);
    int sumOfSquares = computeSumOfSquaresTo(num);
    return Math.abs(sumOfSquares - squareOfSum);
  }

}

@@ -1,12 +1,48 @@
+import java.util.stream.IntStream;%0A%0A
 public final
@@ -134,109 +134,65 @@
     
-int sum = 0;%0A    for (int i = 0; i %3C= num; i++) %7B%0A      sum += i;%0A    %7D%0A    return (int) Math.pow(
+return (int) Math.pow(IntStream.rangeClosed(0, num).
 sum
+()
 , 2)

Use stream for squareOfSum