Re:In Java 3 = 12
by kelnos on Wednesday November 15, 2017 @03:22AM
(#15702264)
Eh, it's just a design decision. They could have required that people construct strings using printf-style formatting (which you can do, with String.format(), but isn't required), or have some sort of interpolation (like Scala does with s"This var is $foo"), but they just opted to let people concat with + instead. You could argue it any way, I suppose; there's no one right answer.
The behavior in the OP's example is unsurprising for a language that defines + to be left-associative and has a well-defined order of operations.
The behavior in the OP's example is unsurprising for a language that defines + to be left-associative and has a well-defined order of operations.