collect() method of Stream is a mutable reduction. Based on Java Documenation:
A mutable reduction operation accumulates input elements into a mutable result container, such as a Collection or StringBuilder, as it processes the elements in the stream.
I tried the following and it compiles without issue.
Stream<String> stream1 = Stream.of("w", "o", "l", "f");
String word = stream1.collect(String::new, String::concat, String::concat);
System.out.println(word);
If the supplier is a StringBuffer, I view the collect operation as elements will be appended to the supplied StringBuffer.
How does mutable reduction works here since String is an immutable object? Will it be the same as reduce operation where a new object is created everytime the accumulator is implemented?