Before Java 9, javac always generated StringBuilder calls for string concatenation (or StringBuffer prior to Java 2). Using + is less verbose, generates the same code, is more readable, and, when we do finally bump the compile target, will generate better code.
Peter On Sun, Dec 15, 2024, 7:13 AM Elliotte Rusty Harold <[email protected]> wrote: > Thanks. In that case I'm -1 on this since it is not available in Java > 8, and even in Java 9 is only possible, not necessarily implemented. > > We can revisit in a few years if the JDK has moved on by then. > > On Sun, Dec 15, 2024 at 1:05 AM Peter Burka <[email protected]> wrote: > > > > I presume this is referring to > > https://openjdk.org/jeps/280 (JEP 280: Indify String Concatenation) > which > > was implemented in Java 9. > > > > On Sat, Dec 14, 2024, 6:26 PM Elliotte Rusty Harold <[email protected]> > > wrote: > > > > > On Sat, Dec 14, 2024 at 3:08 PM Serw <[email protected]> wrote: > > > > > > > Would the community support using string concatenation over > StringBuilder > > > > for simple cases? Modern JDKs (8+) optimize string concatenation > > > > efficiently, making it both concise and performant. > > > > > > Interesting. Do you have a reference for that? > > > > > > -- > > > Elliotte Rusty Harold > > > [email protected] > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [email protected] > > > For additional commands, e-mail: [email protected] > > > > > > > > > > -- > Elliotte Rusty Harold > [email protected] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
