posted 10 months ago
Look carefully at the parameters of the reduce() function.
We passed in an Integer as the identity, so we can substitute Integer for U. We also know that the stream consists of StringBuilder, so we substitute StringBuilder for T.
So the accumulator is a function that accepts an Integer and a StringBuilder. That means:
And the combiner is a function that takes two Integers:
Now you can easily see why the program is wrong: w, y and z are Integer and thus lack a length() method.