Please correct me if i\'m wrong. In Java 8, for performance reasons, when concatenating several strings by the \"+\" operator StringBuffer was invoked. And the problem of cr
Your loop is creating a new String each time. StringBuilder (not StringBuffer, which is synchronized and should not be used,) avoids instantiating a new object each time.
Java 9 may be adding new features, but I would be surprised if things have changed. This issue is much older than Java 8.
Addition:
Java 9 has modified the way String concatenation is performed when using the "+" operator in a single statement. Up to Java 8, it used a builder. Now, it uses a more efficient approach. However, that does not address using "+=" in a loop.